·  PHP – Syntax – OOP – Classes – Components – Methods – Custom – Scope – Public

 

- Info:

  - Methods are by default declared as public.

  - If you want you can explicitly declare method public by using keyword public.

  - Public methods can be accessed from anywhere.

 

- Example:

  - Creat PHP Console Application Test.php.

 

    Test.php

    <?php

   

      class Person { 

        public function sayExplicit() { echo("Explicitly declared public function.\n");  }         

               function sayImplicit() { echo("Implicitly declared public function.\n"); }

      }

   

      Person::sayExplicit(); //Public functions are accessable through class name.

      $john = new Person();  

      $john->sayImplicit();    

      

    ?>