note 69867 added to function.mysql-fetch-object
| From: | SimonParidon at osu1 dot php dot net | Date: | Sun, 24 Sep 2006 12:53:58 +0000 |
| Subject: | note 69867 added to function.mysql-fetch-object | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117532@lists.php.net to get a copy of this message | ||
The behavior of this function is slightly questionable.
If you have a col in you table containing non-variable-name characters like "-",
mysql_fetch_object will add "impossible variable names" to your object, e.g.
object (
[user-id] => 7
)
You can not access this variable normally with $obj->user-id, because the variable name is
invalid. But you can however access it like this:
$foo = 'user-id';
echo $obj->$foo;
It will correctly output 7, whereas var_dump($obj->user-id) would output int(0) for some reason.
I got this behaviour with PHP 4.4.2.
----
Server IP: 217.13.201.10
Probable Submitter: 84.157.20.130
----
Manual Page -- http://www.php.net/manual/en/function.mysql-fetch-object.php
Edit -- https://master.php.net/note/edit/69867
Del: integrated -- https://master.php.net/note/delete/69867/integrated
Del: useless -- https://master.php.net/note/delete/69867/useless
Del: bad code -- https://master.php.net/note/delete/69867/bad+code
Del: spam -- https://master.php.net/note/delete/69867/spam
Del: non-english -- https://master.php.net/note/delete/69867/non-english
Del: in docs -- https://master.php.net/note/delete/69867/in+docs
Del: other reasons-- https://master.php.net/note/delete/69867
Reject -- https://master.php.net/note/reject/69867
Search -- https://master.php.net/manage/user-notes.php