Created
March 20, 2010 21:01
-
-
Save simeonwillbanks/338905 to your computer and use it in GitHub Desktop.
PHP: Property Accessors Example Person Version 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Person { | |
public $first_name; | |
public $last_name; | |
public function __construct($first_name, $last_name) | |
{ | |
$this->first_name = $first_name; | |
$this->last_name = $last_name; | |
} | |
public function full_name() | |
{ | |
return $this->first_name.' '.$this->last_name; | |
} | |
} | |
$me = new Person("Simeon", "Willbanks"); | |
// Why does this have to be a function? | |
// Why can't it be a member? | |
echo $me->full_name(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment