2015-01-18 19:57:09 +01:00
|
|
|
Literals
|
|
|
|
-----
|
|
|
|
<?php
|
|
|
|
|
|
|
|
// magic constants
|
|
|
|
__LINE__;
|
|
|
|
__FILE__;
|
|
|
|
__DIR__;
|
|
|
|
__FUNCTION__;
|
|
|
|
__CLASS__;
|
|
|
|
__TRAIT__;
|
|
|
|
__METHOD__;
|
|
|
|
__NAMESPACE__;
|
|
|
|
|
|
|
|
// not actually literals, but close
|
|
|
|
null;
|
|
|
|
true;
|
|
|
|
false;
|
|
|
|
NULL;
|
|
|
|
TRUE;
|
|
|
|
FALSE;
|
|
|
|
|
|
|
|
// integers (normalized to decimal)
|
|
|
|
0;
|
|
|
|
11;
|
|
|
|
011;
|
|
|
|
0x11;
|
|
|
|
0b11;
|
|
|
|
|
|
|
|
// floats (normalized to ... something)
|
|
|
|
0.;
|
|
|
|
.0;
|
|
|
|
0.0;
|
|
|
|
0e1000;
|
|
|
|
1.0;
|
|
|
|
1e100;
|
|
|
|
1e1000;
|
|
|
|
1E-100;
|
|
|
|
1000000000000000000000000000000000000000000000000000000000000000000000000000000000000;
|
2015-05-01 19:15:33 +02:00
|
|
|
378282246310005.0;
|
2015-05-02 11:48:55 +02:00
|
|
|
10000000000000002.0;
|
2015-01-18 19:57:09 +01:00
|
|
|
|
2016-04-02 15:22:24 +02:00
|
|
|
// strings (single quoted)
|
2015-01-18 19:57:09 +01:00
|
|
|
'a';
|
|
|
|
'a
|
|
|
|
b';
|
|
|
|
'a\'b';
|
2017-12-01 18:31:21 +01:00
|
|
|
'a\b';
|
|
|
|
'a\\';
|
2016-04-02 15:22:24 +02:00
|
|
|
|
|
|
|
// strings (double quoted)
|
2017-12-01 18:31:21 +01:00
|
|
|
"a";
|
|
|
|
"a\nb";
|
2015-01-18 19:57:09 +01:00
|
|
|
"a'b";
|
|
|
|
"a\b";
|
|
|
|
"$a";
|
|
|
|
"a$b";
|
2015-03-11 19:02:44 +01:00
|
|
|
"$a$b";
|
|
|
|
"$a $b";
|
2015-01-18 19:57:09 +01:00
|
|
|
"a${b}c";
|
|
|
|
"a{$b}c";
|
|
|
|
"a$a[b]c";
|
2015-03-11 19:02:44 +01:00
|
|
|
"\{$A}";
|
|
|
|
"\{ $A }";
|
|
|
|
"\\{$A}";
|
|
|
|
"\\{ $A }";
|
|
|
|
"{$$A}[B]";
|
|
|
|
"$$A[B]";
|
2015-01-18 19:57:09 +01:00
|
|
|
|
|
|
|
// make sure indentation doesn't mess anything up
|
|
|
|
function foo()
|
|
|
|
{
|
|
|
|
"a\nb";
|
|
|
|
'a
|
|
|
|
b';
|
|
|
|
'a
|
|
|
|
b';
|
|
|
|
}
|
2016-02-20 18:55:48 +01:00
|
|
|
|
|
|
|
// shell exec (similar to double quoted string)
|
|
|
|
`foo`;
|
|
|
|
`foo$a`;
|
|
|
|
`foo{$a}bar`;
|
|
|
|
`\`\'\"`;
|
2015-01-18 19:57:09 +01:00
|
|
|
-----
|
|
|
|
// magic constants
|
|
|
|
__LINE__;
|
|
|
|
__FILE__;
|
|
|
|
__DIR__;
|
|
|
|
__FUNCTION__;
|
|
|
|
__CLASS__;
|
|
|
|
__TRAIT__;
|
|
|
|
__METHOD__;
|
|
|
|
__NAMESPACE__;
|
|
|
|
// not actually literals, but close
|
|
|
|
null;
|
|
|
|
true;
|
|
|
|
false;
|
|
|
|
NULL;
|
|
|
|
TRUE;
|
|
|
|
FALSE;
|
|
|
|
// integers (normalized to decimal)
|
|
|
|
0;
|
|
|
|
11;
|
2016-03-09 21:10:55 +01:00
|
|
|
011;
|
|
|
|
0x11;
|
|
|
|
0b11;
|
2015-01-18 19:57:09 +01:00
|
|
|
// floats (normalized to ... something)
|
|
|
|
0.0;
|
|
|
|
0.0;
|
|
|
|
0.0;
|
|
|
|
0.0;
|
|
|
|
1.0;
|
|
|
|
1.0E+100;
|
2016-12-11 16:31:59 +01:00
|
|
|
\INF;
|
2015-01-18 19:57:09 +01:00
|
|
|
1.0E-100;
|
|
|
|
1.0E+84;
|
2015-05-01 19:15:33 +02:00
|
|
|
378282246310005.0;
|
2015-05-02 11:48:55 +02:00
|
|
|
10000000000000002.0;
|
2016-04-02 15:22:24 +02:00
|
|
|
// strings (single quoted)
|
2015-01-18 19:57:09 +01:00
|
|
|
'a';
|
|
|
|
'a
|
|
|
|
b';
|
|
|
|
'a\'b';
|
2017-12-01 18:31:21 +01:00
|
|
|
'a\\b';
|
|
|
|
'a\\';
|
2016-04-02 15:22:24 +02:00
|
|
|
// strings (double quoted)
|
2017-12-01 18:31:21 +01:00
|
|
|
"a";
|
|
|
|
"a\nb";
|
2016-04-02 15:22:24 +02:00
|
|
|
"a'b";
|
|
|
|
"a\\b";
|
2015-01-18 19:57:09 +01:00
|
|
|
"{$a}";
|
|
|
|
"a{$b}";
|
2015-03-11 19:02:44 +01:00
|
|
|
"{$a}{$b}";
|
|
|
|
"{$a} {$b}";
|
2015-01-18 19:57:09 +01:00
|
|
|
"a{$b}c";
|
|
|
|
"a{$b}c";
|
|
|
|
"a{$a['b']}c";
|
2015-03-11 19:02:44 +01:00
|
|
|
"\\{{$A}}";
|
|
|
|
"\\{ {$A} }";
|
|
|
|
"\\{$A}";
|
|
|
|
"\\{ {$A} }";
|
|
|
|
"{${$A}}[B]";
|
|
|
|
"\${$A['B']}";
|
2015-01-18 19:57:09 +01:00
|
|
|
// make sure indentation doesn't mess anything up
|
|
|
|
function foo()
|
|
|
|
{
|
2016-04-02 15:22:24 +02:00
|
|
|
"a\nb";
|
2015-01-18 19:57:09 +01:00
|
|
|
'a
|
|
|
|
b';
|
|
|
|
'a
|
|
|
|
b';
|
|
|
|
}
|
2016-02-20 18:55:48 +01:00
|
|
|
// shell exec (similar to double quoted string)
|
|
|
|
`foo`;
|
|
|
|
`foo{$a}`;
|
|
|
|
`foo{$a}bar`;
|
|
|
|
`\`\\'\\"`;
|