Created
April 15, 2016 21:31
-
-
Save tiggreen/0c0bedbdfef3380f61cfc42f19527da0 to your computer and use it in GitHub Desktop.
PHP Trait Use Example
This file contains 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 HelloBufferWorld { | |
public function sayHello() { | |
echo 'Hello Buffer Engineers!'; | |
} | |
} | |
class ASampleClass { | |
use HelloBufferWorld; | |
} | |
// create an object of ASampleClass class | |
$obj = new ASampleClass(); | |
$obj->sayHello(); // this will print "Hello Buffer Engineers!" | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment