note 108141 added to language.variables.variable
| From: | ckelley at ca-cycleworks dot com | Date: | Sun, 01 Apr 2012 03:34:42 +0000 |
| Subject: | note 108141 added to language.variables.variable | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186931@lists.php.net to get a copy of this message | ||
Unlike as stated near the bottom of this thread, using variables to point to an object does not
always work. In my case, that is the object returned from
new
SimpleXMLElement($xmlstr).
Once my nodes got 3 and 4 deep to access customer information from orders, I knew something drastic
had to be done.
<?php
$xmlstr
="<xml><foo><bar><you>Blah</you></bar></foo></xml>";
$xml=SimpleXMLElement($xmlstr);
// no matter what you feed it, it works...
$lvl1="\$xml->foo";
echo n($lvl1."->bar->you");
// n will return Blah as we would hope.
function n($node){
global $xml;
return eval("return $node;");
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 98.175.243.214
----
Manual Page -- http://www.php.net/manual/en/language.variables.variable.php
Edit -- https://master.php.net/note/edit/108141
Del: integrated -- https://master.php.net/note/delete/108141/integrated
Del: useless -- https://master.php.net/note/delete/108141/useless
Del: bad code -- https://master.php.net/note/delete/108141/bad+code
Del: spam -- https://master.php.net/note/delete/108141/spam
Del: non-english -- https://master.php.net/note/delete/108141/non-english
Del: in docs -- https://master.php.net/note/delete/108141/in+docs
Del: other reasons-- https://master.php.net/note/delete/108141
Reject -- https://master.php.net/note/reject/108141
Search -- https://master.php.net/manage/user-notes.php