Re: Retrieving values from array on a class
| From: | Stut | Date: | Mon, 16 Oct 2006 21:15:42 +0000 |
| Subject: | Re: Retrieving values from array on a class | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-243225@lists.php.net to get a copy of this message | ||
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