tags:

views:

66

answers:

1

I have a class that looks like this:

utils/Result.php

<?php

class Result
{
    public static function ok()
    {
     echo "OK";
    } 
}

If I create the following script

./sandbox.php

<?php

require_once("utils/Result.php");

print_r(Result::ok());

And run it with php sandbox.php it works fine. But if I do the following: cd test && php ../sandbox.php it gives me the following error

PHP Fatal error:  Call to undefined method Result::ok() in /mnt/hgfs/leapback/sandbox.php on line 5

Now, realize that the require statement seems to be working. If I add a property to the Result class, and use print_r on an instance of it, it looks right. But the static methods disappear. I'm very confused. I'm running php 5.2.6.

+2  A: 

Do you have a 'utils/Result.php' file in the directory you have changed to (test)? If yes, it will be included instead of the original file.

soulmerge
No. I just made a new directory to be certain. It still happens.
Sean Clark Hess
Dang... You're all right. I had "include_path" creep because I idiotically set the php.ini path to globally include another project's code. Thanks guys
Sean Clark Hess