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 | |
require_once __DIR__.'/vendor/autoload.php'; | |
use Symfony\Component\HttpKernel\HttpCache\Esi; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Response; | |
$esi = new Esi; | |
$request = Request::createFromGlobals(); | |
$response = new Response(); | |
$content = '<h1>This pages refreshes every 10 seconds</h1>'; |
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
{ | |
"require": { | |
"silex/silex": "1.3.*", | |
"symfony/twig-bridge": "2.7", | |
"twig/twig": "1.23.*" | |
} | |
} |
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 | |
/** | |
* Scalar type declarations | |
*/ | |
//declare(strict_types=1); | |
function add(int $a, int $b) { | |
return $a + $b; | |
} |
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 | |
/** | |
* Return type declarations | |
*/ | |
//declare(strict_types=1); | |
function add(int $a, int $b): int{ | |
return (string)($a + $b); | |
} |
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 | |
/** | |
* Anonymous classes | |
*/ | |
$foo = new class { | |
public function foo() { | |
return "bar"; | |
} | |
}; |
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 | |
/** | |
* Closure::call() | |
*/ | |
class Foo | |
{ | |
private $foo = 'bar'; | |
} |
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 | |
/** | |
* Generator delegation | |
*/ | |
function gen() | |
{ | |
yield 1; | |
yield 2; | |
yield from gen2(); |
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 | |
/** | |
* Generator return expressions | |
*/ | |
$gen = (function() { | |
yield 1; | |
yield 2; | |
return 3; |
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 | |
/** | |
* Null coalesce operator | |
*/ | |
$array = ['foo'=>'bar']; | |
//PHP5 style | |
$message = isset($array['foo']) ? $array['foo'] : 'not set'; | |
echo $message.PHP_EOL; |
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 | |
/** | |
* Space ship operator | |
*/ | |
$array = [ | |
"1 <=> 1" => 1 <=> 1, | |
"1 <=> 2" =>1 <=> 2, | |
"2 <=> 1" => 2 <=> 1 | |
]; |