language/types/string.xml
2832df2e1bd7daa1ec29ffb167dce1c9feb8cc6b
2832df2e1bd7daa1ec29ffb167dce1c9feb8cc6b
...
...
@@ -76,34 +76,35 @@
76
76
</simpara>
77
77
</note>
78
78
79
-
<informalexample>
79
+
<example>
80
+
<title>Syntax Variants</title>
80
81
<programlisting role="php">
81
82
<![CDATA[
82
83
<?php
83
-
echo 'this is a simple string';
84
+
echo 'this is a simple string', PHP_EOL;
84
85
85
86
echo 'You can also have embedded newlines in
86
87
strings this way as it is
87
-
okay to do';
88
+
okay to do', PHP_EOL;
88
89
89
90
// Outputs: Arnold once said: "I'll be back"
90
-
echo 'Arnold once said: "I\'ll be back"';
91
+
echo 'Arnold once said: "I\'ll be back"', PHP_EOL;
91
92
92
93
// Outputs: You deleted C:\*.*?
93
-
echo 'You deleted C:\\*.*?';
94
+
echo 'You deleted C:\\*.*?', PHP_EOL;
94
95
95
96
// Outputs: You deleted C:\*.*?
96
-
echo 'You deleted C:\*.*?';
97
+
echo 'You deleted C:\*.*?', PHP_EOL;
97
98
98
99
// Outputs: This will not expand: \n a newline
99
-
echo 'This will not expand: \n a newline';
100
+
echo 'This will not expand: \n a newline', PHP_EOL;
100
101
101
102
// Outputs: Variables do not $expand $either
102
-
echo 'Variables do not $expand $either';
103
+
echo 'Variables do not $expand $either', PHP_EOL;
103
104
?>
104
105
]]>
105
106
</programlisting>
106
-
</informalexample>
107
+
</example>
107
108
108
109
</sect3>
109
110
...
...
@@ -111,7 +112,7 @@ echo 'Variables do not $expand $either';
111
112
<title>Double quoted</title>
112
113
113
114
<para>
114
-
If the <type>string</type> is enclosed in double-quotes ("), PHP will
115
+
If the <type>string</type> is enclosed in double-quotes (<literal>"</literal>), PHP will
115
116
interpret the following escape sequences for special characters:
116
117
</para>
117
118
...
...
@@ -199,7 +200,7 @@ echo 'Variables do not $expand $either';
199
200
<para>
200
201
The most important feature of double-quoted <type>string</type>s is the fact
201
202
that variable names will be expanded. See
202
-
<link linkend="language.types.string.parsing">string parsing</link> for
203
+
<link linkend="language.types.string.parsing">string interpolation</link> for
203
204
details.
204
205
</para>
205
206
</sect3>
...
...
@@ -281,7 +282,7 @@ c
281
282
&example.outputs.73;
282
283
<screen>
283
284
<![CDATA[
284
-
PHP Parse error: Invalid body indentation level (expecting an indentation level of at least 3) in example.php on line 4
285
+
Parse error: Invalid body indentation level (expecting an indentation level of at least 3) in example.php on line 4
285
286
]]>
286
287
</screen>
287
288
</example>
...
...
@@ -298,7 +299,7 @@ PHP Parse error: Invalid body indentation level (expecting an indentation level
298
299
299
300
<example>
300
301
<title>Different indentation for body (spaces) closing identifier</title>
301
-
<programlisting role="php">
302
+
<programlisting role="php" annotations="non-interactive">
302
303
<![CDATA[
303
304
<?php
304
305
// All the following code do not work.
...
...
@@ -328,7 +329,7 @@ PHP Parse error: Invalid body indentation level (expecting an indentation level
328
329
&example.outputs.73;
329
330
<screen>
330
331
<![CDATA[
331
-
PHP Parse error: Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
332
+
Parse error: Invalid indentation - tabs and spaces cannot be mixed in example.php line 8
332
333
]]>
333
334
</screen>
334
335
</example>
...
...
@@ -389,15 +390,15 @@ END, 'd e f'];
389
390
&example.outputs.73;
390
391
<screen>
391
392
<![CDATA[
392
-
PHP Parse error: syntax error, unexpected identifier "ING", expecting "]" in example.php on line 6
393
+
Parse error: syntax error, unexpected identifier "ING", expecting "]" in example.php on line 5
393
394
]]>
394
395
</screen>
395
396
</example>
396
397
397
398
<simpara>
398
399
To avoid this problem, it is safe to follow the simple rule:
399
-
<emphasis>do not choose as a closing identifier if it appears in the body
400
-
of the text</emphasis>.
400
+
<emphasis>do not choose a word that appears in the body of the text
401
+
as a closing identifier</emphasis>.
401
402
</simpara>
402
403
403
404
</warning>
...
...
@@ -539,7 +540,7 @@ EOD
539
540
540
541
<example>
541
542
<title>Using Heredoc to initialize static values</title>
542
-
<programlisting role="php">
543
+
<programlisting role="php" annotations="non-interactive">
543
544
<![CDATA[
544
545
<?php
545
546
// Static variables
...
...
@@ -592,7 +593,7 @@ FOOBAR;
592
593
<para>
593
594
Nowdocs are to single-quoted strings what heredocs are to double-quoted
594
595
strings. A nowdoc is specified similarly to a heredoc, but <emphasis>no
595
-
parsing is done</emphasis> inside a nowdoc. The construct is ideal for
596
+
String interpolation is done</emphasis> inside a nowdoc. The construct is ideal for
596
597
embedding PHP code or other large blocks of text without the need for
597
598
escaping. It shares some features in common with the SGML
598
599
<literal><![CDATA[ ]]></literal> construct, in that it declares a
...
...
@@ -668,7 +669,7 @@ This should not print a capital 'A': \x41]]>
668
669
669
670
<example>
670
671
<title>Static data example</title>
671
-
<programlisting role="php">
672
+
<programlisting role="php" annotations="non-interactive">
672
673
<![CDATA[
673
674
<?php
674
675
class foo {
...
...
@@ -684,38 +685,31 @@ EOT;
684
685
</sect3>
685
686
686
687
<sect3 xml:id="language.types.string.parsing">
687
-
<title>Variable parsing</title>
688
+
<title>String interpolation</title>
688
689
689
690
<simpara>
690
691
When a <type>string</type> is specified in double quotes or with heredoc,
691
-
<link linkend="language.variables">variables</link> are parsed within it.
692
+
<link linkend="language.variables">variables</link> can be substituted within it.
692
693
</simpara>
693
694
694
695
<simpara>
695
696
There are two types of syntax: a
696
-
<link linkend="language.types.string.parsing.simple">simple</link> one and a
697
-
<link linkend="language.types.string.parsing.complex">complex</link> one.
698
-
The simple syntax is the most common and convenient. It provides a way to
697
+
<link linkend="language.types.string.parsing.basic">basic</link> one and an
698
+
<link linkend="language.types.string.parsing.advanced">advanced</link> one.
699
+
The basic syntax is the most common and convenient. It provides a way to
699
700
embed a variable, an <type>array</type> value, or an <type>object</type>
700
701
property in a <type>string</type> with a minimum of effort.
701
702
</simpara>
702
703
703
-
<simpara>
704
-
The complex syntax can be recognised by the
705
-
curly braces surrounding the expression.
706
-
</simpara>
707
-
708
-
<sect4 xml:id="language.types.string.parsing.simple">
709
-
<title>Simple syntax</title>
710
-
704
+
<sect4 xml:id="language.types.string.parsing.basic">
705
+
<title>Basic syntax</title>
711
706
<simpara>
712
-
If a dollar sign (<literal>$</literal>) is encountered, the parser will
713
-
greedily take as many tokens as possible to form a valid variable name.
714
-
Enclose the variable name in curly braces to explicitly specify the end of
715
-
the name.
707
+
If a dollar sign (<literal>$</literal>) is encountered, the characters
708
+
that follow it which can be used in a variable name will be interpreted
709
+
as such and substituted.
716
710
</simpara>
717
-
718
-
<informalexample>
711
+
<example>
712
+
<title>String Interpolation</title>
719
713
<programlisting role="php">
720
714
<![CDATA[
721
715
<?php
...
...
@@ -723,12 +717,6 @@ $juice = "apple";
723
717
724
718
echo "He drank some $juice juice." . PHP_EOL;
725
719
726
-
// Unintended. "s" is a valid character for a variable name, so this refers to $juices, not $juice.
727
-
echo "He drank some juice made of $juices." . PHP_EOL;
728
-
729
-
// Explicitly specify the end of the variable name by enclosing the reference in braces.
730
-
echo "He drank some juice made of {$juice}s.";
731
-
732
720
?>
733
721
]]>
734
722
</programlisting>
...
...
@@ -736,43 +724,131 @@ echo "He drank some juice made of {$juice}s.";
736
724
<screen>
737
725
<![CDATA[
738
726
He drank some apple juice.
739
-
He drank some juice made of .
740
-
He drank some juice made of apples.
741
727
]]>
742
728
</screen>
743
-
</informalexample>
729
+
</example>
744
730
745
731
<simpara>
746
-
Similarly, an <type>array</type> index or an <type>object</type> property
747
-
can be parsed. With array indices, the closing square bracket
748
-
(<literal>]</literal>) marks the end of the index. The same rules apply to
749
-
object properties as to simple variables.
732
+
Formally, the structure for the basic variable substitution syntax is
733
+
as follows:
750
734
</simpara>
735
+
<informalexample>
736
+
<programlisting>
737
+
<![CDATA[
738
+
string-variable::
739
+
variable-name (offset-or-property)?
740
+
| ${ expression }
751
741
752
-
<example><title>Simple syntax example</title>
753
-
<programlisting role="php">
742
+
offset-or-property::
743
+
offset-in-string
744
+
| property-in-string
745
+
746
+
offset-in-string::
747
+
[ name ]
748
+
| [ variable-name ]
749
+
| [ integer-literal ]
750
+
751
+
property-in-string::
752
+
-> name
753
+
754
+
variable-name::
755
+
$ name
756
+
757
+
name::
758
+
[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*
759
+
760
+
]]>
761
+
</programlisting>
762
+
</informalexample>
763
+
764
+
<warning>
765
+
<para>
766
+
The <literal>${ expression }</literal> syntax is deprecated as of
767
+
PHP 8.2.0, as it can be interpreted as
768
+
<link linkend="language.variables.variable">variable variables</link>:
769
+
<informalexample>
770
+
<programlisting role="php">
754
771
<![CDATA[
755
772
<?php
756
-
$juices = array("apple", "orange", "koolaid1" => "purple");
773
+
const foo = 'bar';
774
+
$foo = 'foo';
775
+
$bar = 'bar';
776
+
var_dump("${foo}");
777
+
var_dump("${(foo)}");
778
+
?>
779
+
]]>
780
+
</programlisting>
781
+
&example.outputs.82;
782
+
<screen>
783
+
<![CDATA[
784
+
Deprecated: Using ${var} in strings is deprecated, use {$var} instead in file on line 6
757
785
758
-
echo "He drank some $juices[0] juice.".PHP_EOL;
759
-
echo "He drank some $juices[1] juice.".PHP_EOL;
760
-
echo "He drank some $juices[koolaid1] juice.".PHP_EOL;
786
+
Deprecated: Using ${expr} (variable variables) in strings is deprecated, use {${expr}} instead in file on line 9
787
+
string(3) "foo"
788
+
string(3) "bar"
789
+
]]>
790
+
</screen>
791
+
&example.outputs;
792
+
<screen>
793
+
<![CDATA[
794
+
string(3) "foo"
795
+
string(3) "bar"
796
+
]]>
797
+
</screen>
798
+
</informalexample>
799
+
The <link linkend="language.types.string.parsing.advanced">advanced</link>
800
+
string interpolation syntax should be used instead.
801
+
</para>
802
+
</warning>
761
803
762
-
class people {
763
-
public $john = "John Smith";
764
-
public $jane = "Jane Smith";
765
-
public $robert = "Robert Paulsen";
804
+
<note>
805
+
<simpara>
806
+
If it is not possible to form a valid name the dollar sign remains
807
+
as verbatim in the string:
808
+
</simpara>
809
+
<informalexample>
810
+
<programlisting role="php">
811
+
<![CDATA[
812
+
<?php
813
+
echo "No interpolation $ has happened\n";
814
+
echo "No interpolation $\n has happened\n";
815
+
echo "No interpolation $2 has happened\n";
816
+
?>
817
+
]]>
818
+
</programlisting>
819
+
&example.outputs;
820
+
<screen>
821
+
<![CDATA[
822
+
No interpolation $ has happened
823
+
No interpolation $
824
+
has happened
825
+
No interpolation $2 has happened
826
+
]]>
827
+
</screen>
828
+
</informalexample>
829
+
</note>
766
830
767
-
public $smith = "Smith";
831
+
<example>
832
+
<title>Interpolating the value of the first dimension of an array or property</title>
833
+
<programlisting role="php">
834
+
<![CDATA[
835
+
<?php
836
+
$juices = array("apple", "orange", "string_key" => "purple");
837
+
838
+
echo "He drank some $juices[0] juice.";
839
+
echo PHP_EOL;
840
+
echo "He drank some $juices[1] juice.";
841
+
echo PHP_EOL;
842
+
echo "He drank some $juices[string_key] juice.";
843
+
echo PHP_EOL;
844
+
845
+
class A {
846
+
public $s = "string";
768
847
}
769
848
770
-
$people = new people();
849
+
$o = new A();
771
850
772
-
echo "$people->john drank some $juices[0] juice.".PHP_EOL;
773
-
echo "$people->john then said hello to $people->jane.".PHP_EOL;
774
-
echo "$people->john's wife greeted $people->robert.".PHP_EOL;
775
-
echo "$people->robert greeted the two $people->smiths."; // Won't work
851
+
echo "Object value: $o->s.";
776
852
?>
777
853
]]>
778
854
</programlisting>
...
...
@@ -782,14 +858,20 @@ echo "$people->robert greeted the two $people->smiths."; // Won't work
782
858
He drank some apple juice.
783
859
He drank some orange juice.
784
860
He drank some purple juice.
785
-
John Smith drank some apple juice.
786
-
John Smith then said hello to Jane Smith.
787
-
John Smith's wife greeted Robert Paulsen.
788
-
Robert Paulsen greeted the two .
861
+
Object value: string.
789
862
]]>
790
863
</screen>
791
864
</example>
792
865
866
+
<note>
867
+
<simpara>
868
+
The array key must be unquoted, and it is therefore not possible to
869
+
refer to a constant as a key with the basic syntax. Use the
870
+
<link linkend="language.types.string.parsing.advanced">advanced</link>
871
+
syntax instead.
872
+
</simpara>
873
+
</note>
874
+
793
875
<simpara>
794
876
As of PHP 7.1.0 also <emphasis>negative</emphasis> numeric indices are
795
877
supported.
...
...
@@ -816,20 +898,23 @@ Changing the character at index -3 to o gives strong.
816
898
</example>
817
899
818
900
<simpara>
819
-
For anything more complex, you should use the complex syntax.
901
+
For anything more complex, the
902
+
<link linkend="language.types.string.parsing.advanced">advanced</link>
903
+
syntax must be used.
820
904
</simpara>
821
905
</sect4>
822
906
823
-
<sect4 xml:id="language.types.string.parsing.complex">
824
-
<title>Complex (curly) syntax</title>
907
+
<sect4 xml:id="language.types.string.parsing.advanced">
908
+
<title>Advanced (curly) syntax</title>
825
909
826
910
<simpara>
827
-
This isn't called complex because the syntax is complex, but because it
828
-
allows for the use of complex expressions.
911
+
The advanced syntax permits the interpolation of
912
+
<emphasis>variables</emphasis> with arbitrary accessors.
829
913
</simpara>
830
914
831
915
<simpara>
832
-
Any scalar variable, array element or object property with a
916
+
Any scalar variable, array element or object property
917
+
(<modifier>static</modifier> or not) with a
833
918
<type>string</type> representation can be included via this syntax.
834
919
The expression is written the same way as it would appear outside the
835
920
<type>string</type>, and then wrapped in <literal>{</literal> and
...
...
@@ -839,14 +924,22 @@ Changing the character at index -3 to o gives strong.
839
924
literal <literal>{$</literal>. Some examples to make it clear:
840
925
</simpara>
841
926
842
-
<informalexample>
927
+
<example>
928
+
<title>Curly Syntax</title>
843
929
<programlisting role="php">
844
930
<![CDATA[
845
931
<?php
846
-
// Show all errors
847
-
error_reporting(E_ALL);
848
-
932
+
const DATA_KEY = 'const-key';
849
933
$great = 'fantastic';
934
+
$arr = [
935
+
'1',
936
+
'2',
937
+
'3',
938
+
[41, 42, 43],
939
+
'key' => 'Indexed value',
940
+
'const-key' => 'Key with minus sign',
941
+
'foo' => ['foo1', 'foo2', 'foo3']
942
+
];
850
943
851
944
// Won't work, outputs: This is { fantastic}
852
945
echo "This is { $great}";
...
...
@@ -854,8 +947,16 @@ echo "This is { $great}";
854
947
// Works, outputs: This is fantastic
855
948
echo "This is {$great}";
856
949
950
+
class Square {
951
+
public $width;
952
+
953
+
public function __construct(int $width) { $this->width = $width; }
954
+
}
955
+
956
+
$square = new Square(5);
957
+
857
958
// Works
858
-
echo "This square is {$square->width}00 centimeters broad.";
959
+
echo "This square is {$square->width}00 centimeters wide.";
859
960
860
961
861
962
// Works, quoted keys only work using the curly brace syntax
...
...
@@ -863,114 +964,35 @@ echo "This works: {$arr['key']}";
863
964
864
965
865
966
// Works
866
-
echo "This works: {$arr[4][3]}";
967
+
echo "This works: {$arr[3][2]}";
867
968
868
-
// This is wrong for the same reason as $foo[bar] is wrong outside a string.
869
-
// In other words, it will still work, but only because PHP first looks for a
870
-
// constant named foo; an error of level E_NOTICE (undefined constant) will be
871
-
// thrown.
872
-
echo "This is wrong: {$arr[foo][3]}";
969
+
echo "This works: {$arr[DATA_KEY]}";
873
970
874
-
// Works. When using multi-dimensional arrays, always use braces around arrays
971
+
// When using multidimensional arrays, always use braces around arrays
875
972
// when inside of strings
876
-
echo "This works: {$arr['foo'][3]}";
877
-
878
-
// Works.
879
-
echo "This works: " . $arr['foo'][3];
973
+
echo "This works: {$arr['foo'][2]}";
880
974
881
-
echo "This works too: {$obj->values[3]->name}";
975
+
echo "This works: {$obj->values[3]->name}";
882
976
883
-
echo "This is the value of the var named $name: {${$name}}";
977
+
echo "This works: {$obj->$staticProp}";
884
978
885
-
echo "This is the value of the var named by the return value of getName(): {${getName()}}";
979
+
// Won't work, outputs: C:\directory\{fantastic}.txt
980
+
echo "C:\directory\{$great}.txt";
886
981
887
-
echo "This is the value of the var named by the return value of \$object->getName(): {${$object->getName()}}";
888
-
889
-
// Won't work, outputs: This is the return value of getName(): {getName()}
890
-
echo "This is the return value of getName(): {getName()}";
891
-
892
-
// Won't work, outputs: C:\folder\{fantastic}.txt
893
-
echo "C:\folder\{$great}.txt"
894
-
// Works, outputs: C:\folder\fantastic.txt
895
-
echo "C:\\folder\\{$great}.txt"
982
+
// Works, outputs: C:\directory\fantastic.txt
983
+
echo "C:\\directory\\{$great}.txt";
896
984
?>
897
985
]]>
898
-
<!-- maybe it's better to leave this out??
899
-
// this works, but i disencourage its use, since this is NOT
900
-
// involving functions, rather than mere variables, arrays and objects.
901
-
$beer = 'Heineken';
902
-
echo "I'd like to have another {${ strrev('reeb') }}, hips";
903
-
-->
904
986
</programlisting>
905
-
</informalexample>
906
-
907
-
<para>
908
-
It is also possible to access class properties using variables
909
-
within strings using this syntax.
910
-
</para>
911
-
912
-
<informalexample>
913
-
<programlisting role="php">
914
-
<![CDATA[
915
-
<?php
916
-
class foo {
917
-
var $bar = 'I am bar.';
918
-
}
919
-
920
-
$foo = new foo();
921
-
$bar = 'bar';
922
-
$baz = array('foo', 'bar', 'baz', 'quux');
923
-
echo "{$foo->$bar}\n";
924
-
echo "{$foo->{$baz[1]}}\n";
925
-
?>
926
-
]]>
927
-
</programlisting>
928
-
&example.outputs;
929
-
<screen>
930
-
<![CDATA[
931
-
I am bar.
932
-
I am bar.
933
-
]]>
934
-
</screen>
935
-
</informalexample>
987
+
</example>
936
988
937
989
<note>
938
-
<para>
939
-
The value accessed from functions, method calls, static class variables,
940
-
and class constants inside
941
-
<literal>{$}</literal> will be interpreted as the name
942
-
of a variable in the scope in which the string is defined. Using
943
-
single curly braces (<literal>{}</literal>) will not work for
944
-
accessing the return values of functions or methods or the
945
-
values of class constants or static class variables.
946
-
</para>
990
+
<simpara>
991
+
As this syntax allows arbitrary expressions it is possible to use
992
+
<link linkend="language.variables.variable">variable variables</link>
993
+
within the advanced syntax.
994
+
</simpara>
947
995
</note>
948
-
949
-
<informalexample>
950
-
<programlisting role="php">
951
-
<![CDATA[
952
-
<?php
953
-
// Show all errors.
954
-
error_reporting(E_ALL);
955
-
956
-
class beers {
957
-
const softdrink = 'rootbeer';
958
-
public static $ale = 'ipa';
959
-
}
960
-
961
-
$rootbeer = 'A & W';
962
-
$ipa = 'Alexander Keith\'s';
963
-
964
-
// This works; outputs: I'd like an A & W
965
-
echo "I'd like an {${beers::softdrink}}\n";
966
-
967
-
// This works too; outputs: I'd like an Alexander Keith's
968
-
echo "I'd like an {${beers::$ale}}\n";
969
-
?>
970
-
]]>
971
-
</programlisting>
972
-
</informalexample>
973
-
974
996
</sect4>
975
997
</sect3>
976
998
...
...
@@ -1040,18 +1062,21 @@ echo "I'd like an {${beers::$ale}}\n";
1040
1062
// Get the first character of a string
1041
1063
$str = 'This is a test.';
1042
1064
$first = $str[0];
1065
+
var_dump($first);
1043
1066
1044
1067
// Get the third character of a string
1045
1068
$third = $str[2];
1069
+
var_dump($third);
1046
1070
1047
1071
// Get the last character of a string.
1048
1072
$str = 'This is still a test.';
1049
1073
$last = $str[strlen($str)-1];
1074
+
var_dump($last);
1050
1075
1051
1076
// Modify the last character of a string
1052
1077
$str = 'Look at the sea';
1053
1078
$str[strlen($str)-1] = 'e';
1054
-
1079
+
var_dump($str);
1055
1080
?>
1056
1081
]]>
1057
1082
</programlisting>
...
...
@@ -1063,42 +1088,44 @@ $str[strlen($str)-1] = 'e';
1063
1088
</para>
1064
1089
1065
1090
<example>
1066
-
<!-- TODO Update for PHP 8.0 -->
1067
1091
<title>Example of Illegal String Offsets</title>
1068
1092
<programlisting role="php">
1069
1093
<![CDATA[
1070
1094
<?php
1071
1095
$str = 'abc';
1072
1096
1073
-
var_dump($str['1']);
1074
-
var_dump(isset($str['1']));
1097
+
$keys = [ '1', '1.0', 'x', '1x' ];
1075
1098
1076
-
var_dump($str['1.0']);
1077
-
var_dump(isset($str['1.0']));
1099
+
foreach ($keys as $keyToTry) {
1100
+
var_dump(isset($str[$keyToTry]));
1078
1101
1079
-
var_dump($str['x']);
1080
-
var_dump(isset($str['x']));
1102
+
try {
1103
+
var_dump($str[$keyToTry]);
1104
+
} catch (TypeError $e) {
1105
+
echo $e->getMessage(), PHP_EOL;
1106
+
}
1081
1107
1082
-
var_dump($str['1x']);
1083
-
var_dump(isset($str['1x']));
1108
+
echo PHP_EOL;
1109
+
}
1084
1110
?>
1085
1111
]]>
1086
1112
</programlisting>
1087
1113
&example.outputs;
1088
1114
<screen>
1089
1115
<![CDATA[
1090
-
string(1) "b"
1091
1116
bool(true)
1092
-
1093
-
Warning: Illegal string offset '1.0' in /tmp/t.php on line 7
1094
1117
string(1) "b"
1118
+
1095
1119
bool(false)
1120
+
Cannot access offset of type string on string
1096
1121
1097
-
Warning: Illegal string offset 'x' in /tmp/t.php on line 9
1098
-
string(1) "a"
1099
1122
bool(false)
1100
-
string(1) "b"
1123
+
Cannot access offset of type string on string
1124
+
1101
1125
bool(false)
1126
+
1127
+
Warning: Illegal string offset "1x" in Standard input code on line 10
1128
+
string(1) "b"
1102
1129
]]>
1103
1130
</screen>
1104
1131
</example>
1105
1132