Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //* >= PHP 5.3
- namespace ns;
- // */
- //*
- echo 'PHP 5.3+ code testing';
- const CONST_VALUE = 1;
- echo $this::CONST_VALUE;
- echo $a::CONST_VALUE;
- echo CONST_VALUE;
- $this::__construct();
- $obj::__construct();
- $a = $b ?: $d;
- $a = ($b ?: $d) + $c;
- $a = f1() ?: f2();
- $a = ($b ? $c : $d);
- $a = ($b ? $c : $d) + $c;
- $a = (f1() ? f3() : f2());
- if ($b ?: $d) {
- echo 'if ($b ?: $d)';
- }
- if (($b ?: $d) + $c) {
- echo 'if (($b ?: $d) + $c)';
- }
- if (f1() ?: f2()) {
- echo 'if (f1() ?: f2())';
- }
- echo 'goto a';
- goto a;
- $i = 1;
- for (; $i <= 2; ++$i) {
- goto a;
- }
- a:
- echo 'label a';
- echo preg_replace_callback('~-([a-z])~', function($match) {
- return strtoupper($match[1]);
- }, 'hello-world');
- $greet = function($name) {
- printf("Hello %s\r\n", $name);
- };
- $greet('World');
- $greet('PHP');
- $total = 0;
- $tax = 1;
- $callback = function($quantity, $product) use($tax, &$total) {
- $tax = 'tax';
- static $static1 = array(1);
- static $static2;
- $tax = 'tax';
- $tax = --$tax;
- $pricePerItem = constant('PRICE_' . strtoupper($product));
- $total += $pricePerItem * $quantity * ($tax + 1);
- };
- // */
- exit();
- ?>
Add Comment
Please, Sign In to add comment