I have a PHP class file A with a static variable, I have one class file B that uses that class A and instantiates its static variable. i wish to access Class A's ststic varibale from another class C in another file. How do i do this. I tried this

classA.php

<?php
Class A{
   public static $foo = array ();

   public static function doSomething(){
       //... Do some process and instantiate static vairable $face
       $face = outputofsomeprocess();
   }
}
?>
classB.php
<?php
require_once "classA.php";
class B{
    public function dosomethingelse(){
        classA::doSomething();
    }
}
?>

classC.php
<?php
require_once "classA.php";
class C{
    public function dosomethingelse(){
       echo classA::$foo[0];
    }
}
?>

How do I do this correctly, because in classC classA::$foo[0] return null.

echo A::$foo[0];

The class name is A, not classA. Besides that, I dont see foo getting a value anywhere, it is an empty array.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.