Created
August 14, 2013 06:21
-
-
Save rosariogueli/6228475 to your computer and use it in GitHub Desktop.
Simple Class in PHP.
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 SimpleClassPHP{ | |
private $simply; | |
private $name; | |
public function __construct(){ | |
$this->simply = "Hello"; | |
} | |
public function setName($name){ | |
$this->name = $name; | |
return $this; | |
} | |
public function greet(){ | |
if($this->name){ | |
echo $this->simply . " " . $this->name . "!"; | |
}else{ | |
echo $this->simply . "!"; | |
} | |
} | |
} | |
/* Usage Example */ | |
$simpleClass = new SimpleClassPHP(); | |
$simpleClass->setName("Rox") | |
->greet(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment