Skip to content

Instantly share code, notes, and snippets.

@up1
Last active August 29, 2015 14:07
Show Gist options
  • Save up1/bb90ac46e7cb246086c9 to your computer and use it in GitHub Desktop.
Save up1/bb90ac46e7cb246086c9 to your computer and use it in GitHub Desktop.
PHP 5.6
<?php
class Variadic {
function say(...$messages) {
foreach ($messages as $message) {
echo $message . " ";
}
echo "\n";
}
}
$object = new Variadic();
$messages = ['I', 'Love', 'You'];
$object->say(...$messages);
?>
<?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";
?>
<?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