Examples of mutable variables
1<?PHP2 classFoo {3 var $bar= ' I am bar. ';4 var $arr=Array(' I am A. ', ' I am B. ', ' I am C. '));5 var $r= ' I am r. ';6 }7 8 $foo=Newfoo ();9 $bar= ' Bar ';Ten $baz=Array(' foo ', ' Bar ', ' baz ', ' Quux ')); One Echo $foo-$bar. "\ n"; A Echo $foo-$baz[1]. "\ n"; - - $start= ' B '; the $end= ' AR '; - Echo $foo->{$start.$end} . "\ n"; - - $arr= ' arr '; + Echo $foo-$arr[1]. "\ n"; - Echo $foo->{$arr}[1]. "\ n"; + A?>
View Code
Last shown as
1 I am Bar. 2 I am Bar. 3 I am Bar. 4 I am R. 5 I am B.
View Code
Single && double quotation marks
Single quotes: Unlike double quotes and HEREDOC syntax structures, the escape sequences of variables and special characters in single-quote strings will not be replaced.
Examples are
1<?PHP2 3 $s= "Ideone";4 $s 1= ' \\Hello world $s ';//output to \hello world $s5 $s 2= "\\Hello World &&$s";//output for \hello world && Ideone6 Echo $s 1;7 Echo $s 2;8 9 //In addition, the nested part of a string that resembles a self-nesting is not iterative but empty .Ten $s 3= "Hello World"$s 3";//Output as Hello world One Echo $s 3; A?>
View Code