public method : public « Class « PHP






public method

<?php

   class Staff
   {
      private $name;

      public function setName($name) {
         $this->name = $name;
     }
   }

   $staff = new Staff;
   $staff->setName("Mary");

?>

           
       








Related examples in the same category

1.Use public properties directly
2.Public fields
3.A Class with Public Properties
4.Using Class Visibility Operators