sectorclear01 Posted October 11, 2012 Report Share Posted October 11, 2012 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. Quote Link to comment Share on other sites More sharing options...
falkencreative Posted October 11, 2012 Report Share Posted October 11, 2012 $new_name is a parameter inside the method (another name for a "function" within an object: see step 4 on http://killerphp.com/tutorials/object-oriented-php/php-objects-page-1.php). A parameter is a variable that is used within a function/method, so that a programmer can send the function some information for the function/method to use. For example: <?php function add($x,$y) { $total=$x+$y; return $total; } echo "1 + 16 = " . add(1,16); ?> $x and $y are parameters. When "add(1, 16)" is called, $x contains 1 and $y contains 16. The function uses those variables to perform calculation, then returns the results at the end of the function. More info on functions/parameters: http://www.w3schools.com/php/php_functions.asp and http://www.tizag.com/phpT/phpfunctions.php Quote Link to comment Share on other sites More sharing options...
sectorclear01 Posted October 12, 2012 Author Report Share Posted October 12, 2012 $new_name is a parameter inside the method (another name for a "function" within an object: see step 4 on http://killerphp.com/tutorials/object-oriented-php/php-objects-page-1.php). A parameter is a variable that is used within a function/method, so that a programmer can send the function some information for the function/method to use. For example: <?php function add($x,$y) { $total=$x+$y; return $total; } echo "1 + 16 = " . add(1,16); ?> $x and $y are parameters. When "add(1, 16)" is called, $x contains 1 and $y contains 16. The function uses those variables to perform calculation, then returns the results at the end of the function. More info on functions/parameters: http://www.w3schools.com/php/php_functions.asp and http://www.tizag.com/phpT/phpfunctions.php Sir Ben, thank you so much! you explained it very well! till next time! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.