Anyone else care to chime in here? If we're really moving to RC1, I
think it makes sense to lock down as many language-level features as
soon as possible.

-adam

On Thu, 15 Jan 2004, Adam Maccabee Trachtenberg wrote:

> On Thu, 15 Jan 2004, Marcus Boerger wrote:
>
> Marcus --
>
> > Thursday, January 15, 2004, 7:04:09 PM, you wrote:
> >
>
> > > Given an object, $obj, should strval($obj) and settype($obj, 'string')
> > > return $obj->__toString() if it exists?
> >
> > > They currently do not, but (string) $obj does.
> >
> > > Are these three operations supposed to be identical, but with
> > > different syntax? Or are there other differences among them?
> >
> > Looking at the docs i found this:
> > Converting to string
> > You can convert a value to a string using the (string) cast, or the
> > strval() function. String conversion is automatically done in the scope
> > of an expression for you where a string is needed. This happens when
> > you use the echo() or print() functions, or when you compare a variable
> > value to a string. Reading the manual sections on Types and Type Juggling
> > will make the following clearer. See also settype().
> >
> > That means strval($x) is equal to (string)$x.
>
> That's how I believe it. I see (string) as the way people who know C
> cast variables in PHP and strval() as the way non-C programmers cast
> stuff. :)
>
> Later on down on that page, it stays that you can't take a strval() of
> an object, but I think that's only because before __toString() there
> was no meaningful way to handle this.
>
> > Looking at settype() i found this:
> > bool settype ( mixed var, string type)
> > Set the type of variable var to type.
> > [...]
> > See also gettype(), type-casting and type-juggling.
> >
> > That does not sound like typecasting but it dosn't sound like no
> > typecasting being involved too. In other words it is unclear.
>
> I had always considered settype() to be a generic version of strval(),
> intval(), etc. But maybe it's not.
>
> > So i'd go for strval() calling __tostring() and hearing some other meanings
> > on settype().
>
> I would like it if strval() called __toString() and I think it also
> makes sense for settype() to work this way, but maybe it would be good
> to hear from others, in particular maybe the someone who added these
> functions?
>
> -adam
>
>

-- 
[EMAIL PROTECTED]
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to