Skip to content

Instantly share code, notes, and snippets.

@rosariogueli
Created August 14, 2013 06:21
Show Gist options
  • Save rosariogueli/6228475 to your computer and use it in GitHub Desktop.
Save rosariogueli/6228475 to your computer and use it in GitHub Desktop.
Simple Class in PHP.
<?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