Public fields : public « Class « PHP






Public fields


<?php

   class Staff
   {
      public $name;
   }

   $employee = new Staff();
   $employee->name = "Joe";
   $name = $employee->name;
   echo "www.java2s.com: $name";

?>
           
       








Related examples in the same category

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