casting php5 objects
| From: | Curt Zirzow | Date: | Fri, 10 Sep 2004 03:45:21 +0000 |
| Subject: | casting php5 objects | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-12692@lists.php.net to get a copy of this message | ||
In reference to bug #29029 (http://bugs.php.net/29029):
Current casting object behaviour:
int - not able to cast
dobule - notice thrown, returns 1.0
null - will return null
bool - returns 1 (from result of double)
string - user __toString() if applicable or 'Object'
Beyond the ridiculous idea of adding a __toInt(), __toDouble()..
etc. What about the idea that casting int so that it returns the
id of the object, and the double value returns the int casted as a
double value. So:
$o1 = new stdClass();
$o2 = new stdClass();
$o3 = new stdClass();
var_dump((int) $o1); /* 1 */
var_dump((double) $o2); /* 2.0 */
var_dump((int) $o3); /* 3 */
Otherwise, I'll just move this over as a documentation problem.
Curt
--
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about. No, sir. Our model is the trapezoid!