Re: Retrieving values from array on a class

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Lynch wrote:
But I don't think you can even *DO* an include() inside a class
definition, so that should be giving you an error...

You can do an include/require anywhere. However, you cannot declare new functions inside an include and use it to add methods or variables to a class.

-->--inc.php-->--
<?php
    function foo()
    {
        return 'I pity to foo';
    }
--<-----------<--

-->--use.php-->--
<?php
    class bar
    {
        include('inc.php');
    }
    $b = new bar();
    print $b->foo(); // This will not work
    print foo();     // But this will
--<-----------<--

This will not work! foo() is actually defined at the global scope.

-Stut

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux