Another newbie OOP question !

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jeddiki
    Contributor
    • Jan 2009
    • 290

    #1

    Another newbie OOP question !

    With my class set up like this:


    Code:
    class_lib.php
    <?php
    class person {
      var $name;
      var $sp_number; 
          public $height;
          protected $social_insurance;
     
      function __construct($persons_name) {
        $this->name = $persons_name;
      }
    
     function get_name() {
        return $this->name;
      }
    		
    } // end class
    ?>
    I can add properties in my html doc and then print
    them out again with this:

    Code:
    HTML Doc
    <?php
    $stefan = new person("Stefan Mischook"); 			
    echo "Stefan's full name: " . $stefan->get_name()."<br>";
    ?>
    I hope thats correct !

    My question is - this is adding values to the property
    $name. How do I add values to the properties $sp_number
    and $height ?
Working...