This site is mobile accessible. Press the "Tap Here" button to use a different font-size.


Smartphone icons created by Freepik - Flaticon

PHP Static Methods

Static methods can also be called from methods in other classes. To do this, the static method should be public:

Hello World!

<?php
// create a public Static Method
class A {
  public static function welcome() {
    echo "Hello World!";
  }
}

// call the public Static Method
class B {
  public function message() {
    A::welcome();
  }
}

$obj = new B();
echo $obj -> message(); 
?>