I was trying to bend my mind around the concept of the reference operator (&) today and came across an article at http://www.onlamp.com/pub/a/php/2002/09/12/php_foundations.html where the author gave the following example:

<?php
    class test {
        function test($val) {
            global $myref;
            $myref = &$this;
            $this->value = $val;
        }
        function printval() {
            echo "The value of this class is '{$this->value}' <br>";
        }
        function setval($val) {
            $this->value = $val;
        }
    }
?>

My question is actually regarding the line "$myref = &$this;". The author states that this is a reference to the class/object itself. Isn't this like saying outside the class "$myref =& new test;"? What would be the point of referring to itself inside the class in this manner? Thanks for your help in advance!

-Adam Reiswig

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to