note 60703 deleted from language.oop5.overloading by nforbes
| From: | nforbes@php.net | Date: | Fri, 17 Feb 2006 23:16:27 +0000 |
| Subject: | note 60703 deleted from language.oop5.overloading by nforbes | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-103949@lists.php.net to get a copy of this message | ||
Note Submitter: namik at flashmail dot com
Reason: bad code
----
Upon uploading some code from my PHP 5.1.2 test server, I found some troubles running it on my
host's PHP 5.0.5.
__get() can not be private and you can not expect already existing variables to get passed to
__get().
<?php
Kernel = class
{
private static $smarty;
function __construct() { . . . }
function __get($name)
{
if ($name == "smarty") $result = $smarty;
return $result;
}
}
$kernel = new Kernel;
echo $kernel.smarty;
?>
PHP 5.0.5: $smarty is private
PHP 5.1.2: Object id #2
Also, in the documentation above __get is private. This does not work in 5.0.5 but does in 5.1.2