Using Private And Public In Classes

<?php
     class myPHP5Class {
          private $my_variable;
          public function my_method($param) {
               echo "my_method($param)!\n";
               echo "my variable is: ";
               echo "{$this->my_variable}\n";
          }
     }     $myobject = new myPHP5Class();     $myobject->my_method("MyParam");     $myobject->my_variable = 10;
?>

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.