Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3354352
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:15:45+00:00 2026-05-18T02:15:45+00:00

php > require_once(‘System.php’); php > System::users(); PHP Fatal error: Call to undefined method System::users()

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

This seems to happen both from interactive command-line and from the a simple script:

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

System.php is in the PHP include path – and includes properly:

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

I’m having a hard time grasping why it says there is a call to an undefined method when in fact it’s static, it’s there, and should be accessible.

<?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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:15:46+00:00Added an answer on May 18, 2026 at 2:15 am

    Make sure you’re including the right file – perhaps an echo somewhere in the class file and see if it echoes when included. If it wasn’t echoed, you’re getting the wrong System.php file.


    If there is a file that matches the name that you specify in more than one of the include paths, PHP will just pick it up from whatever include path came first. That may or may not be the include path that you expect your files to be read from, which is why I don’t ever rely on that setting and just specify all my includes absolutely. From the manual:

    PHP considers each entry in the include path separately when looking for files to include. It will check the first path, and if it doesn’t find it, check the next path, until it either locates the included file or returns with a warning or an error.

    (Reposted my comment as an answer here, and expanded upon it, for future reference.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a section of code like the following: ---- file.php ---- require_once(mylib.php); function($a,$b)
My first class: <?php require_once( 'error/DisconnectedHandler.php' ); require_once( 'error/NoSuchRequestHandler.php' ); class NetworkManager { public
index.php: <form action=update_db.php method=post> <?php require_once 'modules/' . $currentModule . '.php'; ?> </form> modules/
Here's my Zend code: <?php require_once ('Zend\Form.php'); class Sergio_Form_registrationform extends Zend_Form { public function
I add this class to library/My/Validate/PasswordConfirmation.php <?php require_once 'Zend/Validate/Abstract.php'; class My_Validate_PasswordConfirmation extends Zend_Validate_Abstract {
Consider the following PHP code: <?php require_once(myDBclass.php); class a { private $tablename; private $column;
Here is my code: <?php require_once 'Swift/lib/swift_required.php'; $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465) ->setUsername('me@ff.com') ->setPassword('pass'); $mailer
Everything I read about better PHP coding practices keeps saying don't use require_once because
Specifically I have a PHP command-line script that at a certain point requires input
PHP stores its session information on the file system of the host of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.