Statik ve varolan zaman tanımsız yöntemi diyoruz?

0 Cevap php
php > require_once('System.php');
php > System::users();
PHP Fatal error:  Call to undefined method System::users() in php shell code on line 1

Bu interaktif komut satırından ve basit bir script hem de gerçekleşmesi gibi görünüyor:

<?php
require_once('System.php');
var_dump(System::users());
?>

System.php PHP yolu dahil - ve düzgün içerir:

php > echo (class_exists('System')) ? 'THERE!' : 'WHERE?';
WHERE?
php > require_once('System.php');
php > echo (class_exists('System')) ? 'THERE!' : 'WHERE?';
THERE!
php > System::users();
PHP Fatal error:  Call to undefined method System::users() in php shell code on line 1

Ben orada aslında statik olduğunda tanımsız bir yöntemi bir çağrı var, ve erişilebilir olması gerektiğini söylüyor, neden açgözlü bir sabit zaman yaşıyorum.

<?php
class System
{
    public static function users()
    {
        $users = array();

        if( !$data_array = file('/etc/passwd') )
        {
            return false;
        }

        foreach( $data_array as $line )
        {
            $data = explode(":", $line);
            $user = array_shift($data);

                list(, $uid, $gid, $info, $path, $terminal) = $data;

            $tmp = array();
            $tmp['uid'] = $uid;
            $tmp['gid'] = $gid;
            $tmp['name'] = array_shift(explode(',', $info));
            $tmp['path'] = $path;
            $tmp['terminal'] = $terminal;

            $users[$user] = $tmp;

            unset($tmp);
        }

        return $users;
    }

    public static function user( $user )
    {
        $users = self::users();

        if( array_key_exists($user, $users) )
        {
            return $users[$user];
        }
        else
        {
            return false;
        }
    }
}
?>

PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:49:46)
Copyright (c) 1997-2009 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

0 Cevap