Retrieving values from array on a class

This is a discussion on Retrieving values from array on a class within the PHP General forums, part of the PHP Programming Forums category; Richard Lynch wrote: > But I don't think you can even *DO* an include() inside a class > definition, ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #11 (permalink)  
Old 10-16-2006
Stut
 
Posts: n/a
Default Re: [PHP] Retrieving values from array on a class

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
Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT +1. The time now is 06:01 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0