Skip to content

Instantly share code, notes, and snippets.

@frne
Last active December 31, 2015 17:49
Show Gist options
  • Save frne/8022547 to your computer and use it in GitHub Desktop.
Save frne/8022547 to your computer and use it in GitHub Desktop.
<?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();
<?php
namespace My\Fancy\ClassName\Prefix;
class WontWork {
}
class OnlyFqcnWillWork {
}
// false
class_exists('WontWork');
// true
class_exists('My\Fancy\ClassName\Prefix\OnlyFqcnWillWork');
<?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