Last active
August 29, 2015 14:07
-
-
Save up1/bb90ac46e7cb246086c9 to your computer and use it in GitHub Desktop.
PHP 5.6
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 | |
class Variadic { | |
function say(...$messages) { | |
foreach ($messages as $message) { | |
echo $message . " "; | |
} | |
echo "\n"; | |
} | |
} | |
$object = new Variadic(); | |
$messages = ['I', 'Love', 'You']; | |
$object->say(...$messages); | |
?> |
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 | |
const ONE = 1; | |
// Scalar Expression in constant | |
const TWO = ONE * 2; | |
class HelloWorld { | |
// Scalar Expression in Property | |
const THREE = TWO + 1; | |
// Scalar Expression in Methods | |
public function hello($a = ONE + self::THREE) { | |
return $a; | |
} | |
} | |
echo (new HelloWorld)->hello()."\n"; | |
?> |
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 | |
class Variadic { | |
function say(...$messages) { | |
foreach ($messages as $message) { | |
echo $message . " "; | |
} | |
echo "\n"; | |
} | |
} | |
$object = new Variadic(); | |
$object->say("I"); | |
$object->say("I", "Love"); | |
$object->say("I", "Love", "You"); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment