SV: [PHP4BETA] Session: objects containing objects
| From: | Johan Ekenberg | Date: | Thu, 24 Feb 2000 18:43:59 +0000 |
| Subject: | SV: [PHP4BETA] Session: objects containing objects | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-10891@lists.php.net to get a copy of this message | ||
> if $obj->slot could be written as $obj["slot"], then $obj[$varslot]
> would be possible, too (and is widely use in JavaScript), and we would
> have in praxis $obj->$varslot, which wont work today in php4. But why -
> $arr[$varkey] works!!
$obj->$varname
works very well in PHP4.
<?php
class foo {
var $bar = "content";
}
$obj = new foo;
$barname = "bar";
print $obj->$barname;
?>
The above code will print "content".
You can take it further, just a minute ago I wrote:
"<TD>{$res_id->{$this->Fieldnames[$status_uid_fieldname][DB_Alias]}}</TD>";
{} help us use advanced variable notation inside quoted strings.
Best regards
/Johan Ekenberg