php »ù´¡±Ê¼Ç string
/***************************by
garcon1986********************************/
<?php
// example for strings, single quoted, double quoted
echo 'display a string!<br>';
echo ' this displays
a splitted
string<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 = <<<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;
echo '$str<br>';
echo "$str<p>";
// variable parsing
$beer = "xuehua";
echo "$beer's taste is good<br>";// works; "'" is an invalid character for variable names
echo "he drinks some $beers<br>";// won't work; 's' is a valid character for variable names but the variable is "$beer
echo "he drinks some ${beer}s<br>";//works
echo "he drinks some {$beer}s<br>";//works
error_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
Ïà¹ØÎĵµ£º
ÔÚÉú²úÓ¦ÓÃÖУ¬Ä³Ì¨“Nginx+PHP+MySQL”½Ó¿ÚÊý¾Ý·þÎñÆ÷£¬°çÑݵĽÇɫʮ·ÖÖØÒª£¬Èç¹û·þÎñÆ÷Ó²¼þ»òNginx¡¢MySQL·¢Éú¹ÊÕÏ£¬¶ø¶Ìʱ¼äÄÚÎÞ·¨»Ö¸´£¬ºó¹û½«·Ç³£ÑÏÖØ¡£ÎªÁ˱ÜÃâµ¥µã¹ÊÕÏ£¬ÎÒÉè¼ÆÁË´ËÌ×·½°¸£¬±àдÁËfailover.sh½Å±¾£¬ÊµÏÖÁËË«»ú»¥±¸¡¢È«×Ô¶¯Çл»£¬¹ÊÕÏ×ªÒÆÊ±¼äÖ»Ð輸ʮÃë¡£
¡¡¡¡Ò»¡¢Ë«»ú»¥±¸¡¢È«×Ô¶¯Çл»·½ ......
ºÜ¾ÃûÓÐЩһЩÓÐÓô¦µÄµÄ¶«Î÷ÁË£¡½ñÌì¾Í²»ºúÂÒµÄд¶«Î÷ÁË!дһЩÓÐÓõ졵±È»Ç°ÌáÏÂÊǺܸÐлºÜ¶à¾³£À´ÎÒ²©¿ÍµÄÅóÓÑһϣ¡¶àл´ó¼Ò£¡£¡£¡£¡£¡
½ñÌìдµÄÊǹØÓÚphp»·¾³¼ÜÉèµÄµÚÒ»ÖÖ·½Ê½£¡µ±È»ÎҾͲ»½ØÍ¼ÁË£¡´ó¼ÒÖ»Òª°´ÕÕ²Ù×÷¾Í¿ÉÒÔʵÏֵģ¡
Ò»¡¢°²×° PHP £º±¾ÎÄPHP°²×°Â·¾¶È¡ÎªD:\php\php4\(Ϊ±Ü»ìÏý£¬PHP5.1.x°æ±¾°²×°Â·¾ ......
PHPµÄÖ´ÐÐЧÂÊÊÇÓÐÄ¿¹²¶ÃµÄ£¬ÕâÒ²ÊÇÎÒϲ»¶ËüµÄÔÒòÖ®Ò»£¬ºÍËü³ÆÎª¾øÃî´îµµµÄMysqlÒÔ¼°ApacheÏëÈںϣ¬²»Äܲ»¾ªÌ¾ÆäЧÂÊÁË¡£PHP¸üÐÂÒ²ºÜ¿ì£¬ÕâÀïÁоÙÁËĿǰ×îа汾PHP4.3.2RC4£¨¼¸ºõûÓÐBUGÁË£¬¹À¼ÆÐ´ÍêÕâÆª²»¾ÃºóÕýʽ°æ¾Í³öÁË£©£¬ºÍ×îа汾µÄMysql4.0.13µÄ°²×°¹ý³Ì¡£
¡¡¡¡PHPµÄ°²×°Îļþ¿ÉÒÔÖ±½Óµ½ &nb ......
/***************************by
garcon1986********************************/
<?php
// variable name is sensitive
$var = "sjg";
$Var = "wl";
echo $var.' loves '.$Var.'<br>';
echo "$var, $Var<p>";
//naming conventions for variables
//$4site = 'not y ......
/***************************by
garcon1986********************************/
<?php
//¼òµ¥Ê¾Àý
class SimpleClass
{
public $var = 'a default value';
public function displayVar(){
echo $this->var;
}
}
// create an object´´½¨Ò»¸ö¶ÔÏó
$A = new SimpleClass;
//µ÷Ó÷½·¨
$A -> displayVa ......