Jump to content

MrSpock

New Members
  • Posts

    2
  • Joined

  • Last visited

MrSpock's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. MrSpock

    Php Construct

    class person { var $name; public $height; protected $social_insurance; private $pinn_number; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name){ $this->name = $new_name; } function get_name(){ return $this->name; } } class employee extends person{ function __construct($employee_name) { $this->set_name($employee_name); } } so to use the classes above, using __construct() allows access to set_name and get_name when I call a new object of employee? I'm still struggling to grasp it.
  2. MrSpock

    Php Construct

    I am following the tutorial on Object Oriented PHP (which is something I've always struggled to grasp) and I'm using __construct() throughout the tutorial. Can you explain it in layman's terms as I'm struggle to understand it? For example: class employee extends person { function __construct($employee_name) { $this->set_name($employee_name); } } Why is the __construct() needed here? Many thanks Spock.
×
×
  • Create New...