literals.test 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. Literals
  2. -----
  3. <?php
  4. // magic constants
  5. __LINE__;
  6. __FILE__;
  7. __DIR__;
  8. __FUNCTION__;
  9. __CLASS__;
  10. __TRAIT__;
  11. __METHOD__;
  12. __NAMESPACE__;
  13. // not actually literals, but close
  14. null;
  15. true;
  16. false;
  17. NULL;
  18. TRUE;
  19. FALSE;
  20. // integers (normalized to decimal)
  21. 0;
  22. 11;
  23. 011;
  24. 0x11;
  25. 0b11;
  26. // floats (normalized to ... something)
  27. 0.;
  28. .0;
  29. 0.0;
  30. 0e1000;
  31. 1.0;
  32. 1e100;
  33. 1e1000;
  34. 1E-100;
  35. 1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
  36. 378282246310005.0;
  37. 10000000000000002.0;
  38. // strings (normalized to single quoted)
  39. 'a';
  40. 'a
  41. b';
  42. "a";
  43. "a\nb";
  44. 'a\'b';
  45. "a'b";
  46. "a\b";
  47. <<<'STR'
  48. a\nb$a
  49. {$b}
  50. STR;
  51. // strings (normalized to double quoted)
  52. "$a";
  53. "a$b";
  54. "$a$b";
  55. "$a $b";
  56. "a${b}c";
  57. "a{$b}c";
  58. "a$a[b]c";
  59. "\{$A}";
  60. "\{ $A }";
  61. "\\{$A}";
  62. "\\{ $A }";
  63. "{$$A}[B]";
  64. "$$A[B]";
  65. <<<STR
  66. a\nb$a\n{$b}
  67. STR;
  68. // make sure indentation doesn't mess anything up
  69. function foo()
  70. {
  71. "a\nb";
  72. 'a
  73. b';
  74. 'a
  75. b';
  76. }
  77. -----
  78. // magic constants
  79. __LINE__;
  80. __FILE__;
  81. __DIR__;
  82. __FUNCTION__;
  83. __CLASS__;
  84. __TRAIT__;
  85. __METHOD__;
  86. __NAMESPACE__;
  87. // not actually literals, but close
  88. null;
  89. true;
  90. false;
  91. NULL;
  92. TRUE;
  93. FALSE;
  94. // integers (normalized to decimal)
  95. 0;
  96. 11;
  97. 9;
  98. 17;
  99. 3;
  100. // floats (normalized to ... something)
  101. 0.0;
  102. 0.0;
  103. 0.0;
  104. 0.0;
  105. 1.0;
  106. 1.0E+100;
  107. INF;
  108. 1.0E-100;
  109. 1.0E+84;
  110. 378282246310005.0;
  111. 10000000000000002.0;
  112. // strings (normalized to single quoted)
  113. 'a';
  114. 'a
  115. b';
  116. 'a';
  117. 'a
  118. b';
  119. 'a\'b';
  120. 'a\'b';
  121. 'a\\b';
  122. 'a\\nb$a
  123. {$b}';
  124. // strings (normalized to double quoted)
  125. "{$a}";
  126. "a{$b}";
  127. "{$a}{$b}";
  128. "{$a} {$b}";
  129. "a{$b}c";
  130. "a{$b}c";
  131. "a{$a['b']}c";
  132. "\\{{$A}}";
  133. "\\{ {$A} }";
  134. "\\{$A}";
  135. "\\{ {$A} }";
  136. "{${$A}}[B]";
  137. "\${$A['B']}";
  138. "a\nb{$a}\n{$b}";
  139. // make sure indentation doesn't mess anything up
  140. function foo()
  141. {
  142. 'a
  143. b';
  144. 'a
  145. b';
  146. 'a
  147. b';
  148. }