Re: is this a bug?
| From: | Thijs Lensselink | Date: | Mon, 20 Aug 2007 09:20:24 +0000 |
| Subject: | Re: is this a bug? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-261036@lists.php.net to get a copy of this message | ||
On Mon, 20 Aug 2007 02:24:49 -0300, Augusto Morais <augusto@smartlinks.com.br> wrote:
> I dont know what is happening...
>
>
> Can somebody clarify the situation for me?
>
>
> here is the situation:
>
> i have 3 files:
>
> class.php
> foo.php
> bar.php
>
> // - class.php
> class globalactions {
>
> function include_file($module) {
> if ($module) {
> return ("modules/".$module."/templates/".$module.".php");
> } else { return include("modules/main/templates/index.php"); }
> }
> }
>
>
> // - foo.php
> include "lib/clients.class.php";
> $clients = new clients(); //instatiating the clients class
>
>
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> include $globalactions->include_file("foo"); //return ->
> "modules/foo/templates/foo.php"
>
> var_dump($clients); //will return the object
>
>
>
> OK. All this works. but i want make some changes.
>
> Well.. What i want to do is this:
>
> class.php:
>
> change the line:
> return ("modules/".$module."/templates/".$module.".php");
>
> to:
> return include ("modules/".$module."/templates/".$module.".php");
>
> and in the bar.php:
>
>
> // - bar.php
> include 'class.php';
> $globalactions = new globalactions ();
> $globalactions->include_file("foo"); //return -> "include
> modules/foo/templates/foo.php" // OK. This works.
>
> var_dump($clients); //i dont get the object here. I got NULL!!! why?!?!!?
>
>
>
> What is happening?
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
No this is not a bug. And it also has nothing todo with scoping.
The object "client" returns NULL. This can only happen if the object is not instantiated.
I guess the foo.php file is not included at all.