Guest User

Untitled

a guest
Jan 24th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. <?php
  2.  
  3. //* >= PHP 5.3
  4. namespace ns;
  5. // */
  6.  
  7. //*
  8. echo 'PHP 5.3+ code testing';
  9. const CONST_VALUE = 1;
  10. echo $this::CONST_VALUE;
  11. echo $a::CONST_VALUE;
  12. echo CONST_VALUE;
  13. $this::__construct();
  14. $obj::__construct();
  15. $a = $b ?: $d;
  16. $a = ($b ?: $d) + $c;
  17. $a = f1() ?: f2();
  18. $a = ($b ? $c : $d);
  19. $a = ($b ? $c : $d) + $c;
  20. $a = (f1() ? f3() : f2());
  21.  
  22. if ($b ?: $d) {
  23. echo 'if ($b ?: $d)';
  24. }
  25.  
  26. if (($b ?: $d) + $c) {
  27. echo 'if (($b ?: $d) + $c)';
  28. }
  29.  
  30. if (f1() ?: f2()) {
  31. echo 'if (f1() ?: f2())';
  32. }
  33.  
  34. echo 'goto a';
  35. goto a;
  36.  
  37. $i = 1;
  38.  
  39. for (; $i <= 2; ++$i) {
  40. goto a;
  41. }
  42.  
  43. a:
  44. echo 'label a';
  45. echo preg_replace_callback('~-([a-z])~', function($match) {
  46. return strtoupper($match[1]);
  47. }, 'hello-world');
  48. $greet = function($name) {
  49. printf("Hello %s\r\n", $name);
  50. };
  51. $greet('World');
  52. $greet('PHP');
  53. $total = 0;
  54. $tax = 1;
  55. $callback = function($quantity, $product) use($tax, &$total) {
  56. $tax = 'tax';
  57. static $static1 = array(1);
  58. static $static2;
  59. $tax = 'tax';
  60. $tax = --$tax;
  61. $pricePerItem = constant('PRICE_' . strtoupper($product));
  62. $total += $pricePerItem * $quantity * ($tax + 1);
  63. };
  64. // */
  65. exit();
  66.  
  67. ?>
Add Comment
Please, Sign In to add comment