note 86896 added to language.types.type-juggling
| From: | Jeffrey at osu1 dot php dot net | Date: | Sun, 09 Nov 2008 19:34:57 +0000 |
| Subject: | note 86896 added to language.types.type-juggling | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146321@lists.php.net to get a copy of this message | ||
IMAGINATION REQUIRED...
We can be a witness to PHP's 'type-jugglin' in real-time with a simple implementation
of a MemoryMap. For the sake our purposes, pretend that this is an empty MemoryMap.
+-------+------+------+-------+
| index | $var | type | value |
+-------+------+------+-------+
| 1 | --- | NULL | null |
| 2 | --- | NULL | null |
| 3 | --- | NULL | null |
| 4 | --- | NULL | null |
+-------+------+------+-------+
<?php
# create some variables...
$a = 10;
$b = "Hello";
$c = array(55.45, 98.65);
# Now look at map...
?>
+-------+-------+---------+--------+
| index | $var | type | value |
+-------+-------+---------+--------+
| 1 | $a | INTEGER | 10 |
| 2 | $b | STRING | Hello |
| 3 | $c[0] | FLOAT | 55.45 |
| 4 | $c[1] | FLOAT | 98.65 |
+-------+-------+---------+--------+
<?php
# Now, change the variable types...
$a = "Bye";
$b = 2;
$c[0] = "Buy";
$c[1] = "Now!";
#Look at map...
?>
+-------+-------+---------+--------+
| index | $var | type | value |
+-------+-------+---------+--------+
| 1 | $a | STRING | Bye | <- used to be INTEGER
| 2 | $b | INTEGER | 2 | <- used to be STRING
| 3 | $c[0] | STRING | Buy | <- used to be FLOAT
| 4 | $c[1] | STRING | Right | <- used to be FLOAT
+-------+-------+---------+--------+
----
Server IP: 69.147.83.197
Probable Submitter: 67.150.122.66
----
Manual Page -- http://www.php.net/manual/en/language.types.type-juggling.php
Edit -- https://master.php.net/note/edit/86896
Del: integrated -- https://master.php.net/note/delete/86896/integrated
Del: useless -- https://master.php.net/note/delete/86896/useless
Del: bad code -- https://master.php.net/note/delete/86896/bad+code
Del: spam -- https://master.php.net/note/delete/86896/spam
Del: non-english -- https://master.php.net/note/delete/86896/non-english
Del: in docs -- https://master.php.net/note/delete/86896/in+docs
Del: other reasons-- https://master.php.net/note/delete/86896
Reject -- https://master.php.net/note/reject/86896
Search -- https://master.php.net/manage/user-notes.php