PHP ʖ²ἯTH º󍋼/A Ղ 7. Ѝ ӯ·¨ µ¥ҽºż/A ˫ҽºż/A ¶¨½緻 µ¥ҽºż/H3 echo 'this is a simple string'; echo 'You can also have embedded newlines in strings this way'; echo 'Arnold once said: "I\'ll be back"'; // output:... "I'll be back" echo 'Are you sure you want to delete C:\\*.*?'; // output:... delete C:\*.*? echo 'Are you sure you want to delete C:\*.*?'; // output:... delete C:\*.*? echo 'I am trying to include at this point: \n a newline'; // output:... this point: \n a newline ˫ҽºż/H3 вP º¬ҥ \n \r \t \\ ·´бϟ \$ \" ˫ҽºż/TD \[0-7]{1,3} \x[0-9A-Fa-f]{1,2} ¶¨½緻 ¾¯¸漯B ?php $str = EOD Example of string spanning multiple lines using 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 EOT My name is "$name". I am printing some $foo- foo. Now, I am printing some {$foo- bar[1]}. This should print a capital 'A': \x41 EOT;? ע: ¶¨½緻֧³֊ǠPHP 4 ֐¼ӈ뵄¡£ ±䁿½⎶ Ӑ}֖ӯ·¨£¬һ֖ ¼򵥵ļ/A º͒»֖ ¸´ԓµļ/A ¡£¼򵥓﷨׮ͨӃºͷ½±㣬˼̡¹©K½⎶±䁿£¬ʽשֵ£¬»򕟶ԏ󊴐Եķ½·¨¡£ ¼򵥓﷨ $beer = 'Heineken'; echo "$beer's taste is great"; // works, "'"is an invalid character for varnames echo "He drank some $beers"; // won't work, 's' is a valid character for varnames echo "He drank some ${beer}s"; // works $fruits = array('strawberry' = 'red', 'banana' = 'yellow'); // note that this works differently outside string-quotes. echo "A banana is $fruits[banana]."; echo "This square is $square- width meters broad."; // Won't work. For a solution, see the complex syntax. echo "This square is $square- width00 centimeters broad."; ¸´ԓ£¨»¨(ºţ©ӯ·¨ ?php // Get the first character of a string $str = 'This is a test.'; $first = $str{0}; // Get the last character of a string. $str = 'This is still a test.'; $last = $str{strlen($str)-1};? $foo = 1 + "10.5"; // $foo is float (11.5) $foo = 1 + "-1.3e3"; // $foo is float (-1299) $foo = 1 + "bob-1.3e3"; // $foo is integer (1) $foo = 1 + "bob3"; // $foo is integer (1) $foo = 1 + "10 Small Pigs"; // $foo is integer (11) $foo = 4 + "10.2 Little Piggies"; // $foo is float (14.2) $foo = "10.0 pigs "+ 1; // $foo is float (11) $foo = "10.0 pigs" + 1.0; // $foo is float (11) echo "\$foo==$foo; type is ". gettype ($foo)." br / \n"; º󍋼/A ưµ㼯A ¸¡µ㐍 ɏһ¼¶ ʽש