/***************************bygarcon1986********************************/
<?php// example for strings, single quoted, double quotedecho 'display a string!<br>';echo ' this displaysa splittedstring<br>';echo 'i/'ll be "back"<br>';echo 'she said:"i/'ll be back!"<br>';echo 'the path is c:/programmes/sjg/*.*!'.''.'hello world<br>';echo 'the path is c://prgralles//sjg/*.*<p>';$h = 'hellos';$i = "hellos";echo '$h<br>';echo "$h"."<br>";echo '$i<br>';echo "$i<br>";//heredoc example$str = <<<EODExample of stringspanning multiple linesusing heredoc syntax.EOD;/* More complex example, with variables. */class foo{var $foo;var $bar;function foo(){$this->foo = 'Foo';$this->bar = array('Bar1', 'Bar2', 'Bar3');}}$foo = new foo();$name = 'MyName';echo <<<EOTMy name is "$name". I am printing some $foo->foo.Now, I am printing some {$foo->bar[1]}.This should print a capital 'A': /x41EOT;echo '$str<br>';echo "$str<p>";// variable parsing$beer = "xuehua";echo "$beer's taste is good<br>";// works; "'" is an invalid character for variable namesecho "he drinks some $beers<br>";// won't work; 's' is a valid character for variable names but the variable is "$beerecho "he drinks some ${beer}s<br>";//worksecho "he drinks some {$beer}s<br>";//workserror_reporting(E_ALL);$fruits = array('strawberry' => 'red', 'banana' => 'yellow');echo "A banana is $fruits[banana].<br>";echo "A banana is {$fruits['banana']}.<br>";echo "A banana is {$fruits[banana]}.<br>"; // Works but PHP looks for a constant named banana first as described below.//echo "A banana is . $fruits['banana'].<br>";echo "A banana is " . $fruits['banana'] . ".<br>";echo "This square is $square->width meters broad.<br>";echo "This square is $square->width00 centimeters broad.<br>";$foo = array('a'=> 11, 3 => true);// more complex syntax$great = 'fantastic';echo "This is { $great}<br>"; // Won't work, outputs: This is { fantastic}echo "This is {$great}<br>";// Works, outputs: This is fantasticecho "This is ${great}<br>";// Works, outputs: This is fantasticecho "This square is {$square->width}00 centimeters broad.<br>";echo "This works: {arr[foo][3]}<br>";echo "This works: {$arr['foo'][3]}<br>";echo "This is wrong: {$arr['foo'][3]}<br>";?>