Jump to content

sectorclear01

New Members
  • Posts

    3
  • Joined

  • Last visited

sectorclear01's Achievements

Newbie

Newbie (1/14)

0

Reputation

  1. http://www.killerphp.com/tutorials/object-oriented-php/php-objects-page-3.php Step 13: Constructors All objects can have a special built-in method called a 'constructor'. Constructors allow you to initialise your object's properties (translation: give your properties values,) when you instantiate (create) an object. Note: If you create a __construct() function (it is your choice,) PHP will automatically call the __construct() method/function when you create an object from your class. The 'construct' method starts with two underscores (__) and the word 'construct'. <?php class person { var $name; function __construct($persons_name) { $this->name = $persons_name; } function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> My Note: Sir/Madam, I didn't get the use of method __construct, but no problem with other methods there. If possible, a sample of View Page that uses the __construct will be more clear. Thank you for your response!
  2. Sir Ben, thank you so much! you explained it very well! till next time!
  3. http://killerphp.com/tutorials/object-oriented-php/php-objects-page-1.php Step 5: <?php class person { var $name; function set_name($new_name) { $this->name = $new_name; } function get_name() { return $this->name; } } ?> ### Question ### What is the use of $new_name on that set_name function? What does it mean when the $new_name is inside the open and close parenthesis? I'm just a beginner, thank you for explaining the thought.
×
×
  • Create New...