Last active
December 31, 2015 17:49
-
-
Save frne/8022547 to your computer and use it in GitHub Desktop.
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 | |
interface fooplan | |
{ | |
function getReverseName(); | |
} | |
class foo implements fooplan | |
{ | |
private $name; | |
public function __construct($name = 'Frank') | |
{ | |
$this->name = (string)$name; | |
} | |
public function getReverseName() | |
{ | |
return $this->strrev($this->name); | |
} | |
} | |
$bar = new foo('Jim'); | |
print $bar->getReverseName(); |
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 | |
namespace My\Fancy\ClassName\Prefix; | |
class WontWork { | |
} | |
class OnlyFqcnWillWork { | |
} | |
// false | |
class_exists('WontWork'); | |
// true | |
class_exists('My\Fancy\ClassName\Prefix\OnlyFqcnWillWork'); |
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 | |
trait foo | |
{ | |
public function doSomething() | |
{ | |
echo 'Done'; | |
} | |
} | |
class bar { | |
use foo; | |
public function doSomethingElse() | |
{ | |
echo 'Done'; | |
} | |
} | |
$bar = new bar; | |
$bar->doSomething(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment