php Öеĵ¥ÒýºÅ Ë«ÒýºÅ ·´ÒýºÅµÄ×÷ÓÃ
×Ö·û´®µÄд·¨
×Ö·û´®ÒÔµ¥¡¢Ë«»òµ¹ÒýºÅΧס·Ö±ðÓв»Í¬µÄÒåÒâ¡£
µ¥ÒýºÅ
ÀýÈ磺
$str = 'An apple a day keeps the docter away.'
µ±×Ö·û´®³öÏÖ ' ·ûºÅʱ£¬±ØÐë¼ÓÉÏ£º
'I'm wing'
Ó¦¸Ä³É£º
'I'm wing'
²Å¶Ô£¬ÆäÖÐ ' ¼´³ÆÎªÌøÍÑ×Ö·û (escape character)¡£
Ë«ÒýºÅ
ÒÔË«ÒýºÅΧסµÄ×Ö·û´® PHP »á¶Ô¸Ã×Ö·û´®×ö variable interpolation µÄ¶¯×÷£¬Ò༴×ö±äÁ¿µÄÈ¡´ú£º
$name = "Wing";
echo 'Name: $name';
echo "Name: $name";
Ö´Ðнá¹ûΪ£º
Name: $name
Name: Wing
ÔÚË«ÒýºÅÀïµÄ×Ö·û´®Èç¹ûÓÐ $ (dollar sign)£¬Ö»Òª¸Ä³ÉÌøÍÑ×ÖÔªµÄд·¨¼´¿É£º
$total = 12000
echo "Total: $ $total"; //Êä³ö Total: $ 12000
ÔÚ×ö variable interpolation ʱ£¬±äÁ¿Ãû³ÆÊÇÒÔÒ»¸öÒÔÉϿոñ×öΪ½çÏߣ¬ÀýÈ磺
$n_file = 5;
if ($n_file == 1) {
echo "There are $n_file.";
} else {
echo "There are $n_files.";
}
µ± $n_file ²»Îª 1 ʱ£¬"There are $n_files." PHP Ëù¿´µ½µÄ±äÁ¿Îª $n_files£¬¶ø²»ÊÇÕýÈ·µÄ $n_file£¬ËùÒÔ±ØÐë¸Ä³É£º
$n_file = 5;
if ($n_file == 1) {
echo "There are $n_file.";
} else {
echo "There are {$n_file}s.";
}
µ¥ÒýºÅÄÚµÄË«ÒýºÅ£¬»òÊÇË«ÒýºÅÄڵĵ¥ÒýºÅ¶¼ÊÓΪÓÐЧ×Ö·û£¬²»ÐèʹÓÃÌøÍÑ×Ö·û£¬ÀýÈ磺
echo "I'm a happy bird.";
echo 'I'm a happy "bird"!';
Êä³ö½á¹ûΪ£º
I'm a happy bird.
I'm a happy "bird"!
·´ÒýºÅ
ÀûÓ÷´ÒýºÅ¿ÉÒÔÖ´ÐÐ Unix ϵÄÃüÁ²¢´«»ØÖ´Ðнá¹û¡£ÀýÈ磺
echo `ls -l *.txt`;
±íʾ½« ls -l *.txt ÃüÁîµÄÖ´Ðнá¹ûÊä³ö£¬ÒÔ·´ÒýºÅΧסµÄ×Ö·û´®ÎªÒªÖ´ÐÐµÄ UNIX Ö¸Áî¡£
Ïà¹ØÎĵµ£º
1¡¢Ê×ÏÈͨ¹ý´úÂëÀ´¿´¿´±íÏó£º
<?php
session_start();
if (empty($_SESSION['count'])) {
$_SESSION['count'] = 1;
} else {
$_SESSION['count']++;
}
var_dump($_SESSION);
var_ ......
ÔÚDOSÖнøÐÐMySQLµÄ·ÃÎÊ¿ÉÄÜÂÒÂëµÄÇé¿öÓÐÈýÖÖ£¬
Ê×ÏÈ£¬Òª×öµÄÊǼì²éMySQLµÄÅäÖ㬰²×°µÄʱºòÑ¡Ôñutf-8µÄÓïÑÔ»·¾³»áʡȥºÜ¶àµÄÂé·³
1. ¼ì²éMySQLµÄ·þÎñ¶Ë¡¢¿Í»§¶ËµÄÓïÑÔÉèÖÃÊÇ·ñΪ“utf8”£¬²»ÊǵϰÊÖ¶¯½«my.int¸ü¸Ä¹ýÀ´£»
2. ÔÚPHP½øÐеÚÒ»´Îmysql_query֮ǰÉèÖÃʹÓÃÁ¬½ÓµÄ×Ö·û¼¯Îª"SET N ......
PHPÖÐÀàµÄ·½·¨Ò²ºÍC++ͨ¹ý¹Ø¼ü×Ö private
¡¢Public
¡¢ protected
À´¿ØÖƵġ£Ï±ßÊÇÏêϸ˵Ã÷£º
1¡¢private
º¯ÊýǰʹÓùؼü×ÖPrivate±íʾº¯ÊýÊÇ˽Óеģ¬Ë½ÓеÄÒâ˼¹ËÃû˼Ò壬Õë¶Ôµ±Ç°Àà˽ÓУ¬ÎÞÂÛÊÇËûµÄ×ÓÀ໹ÊÇËûµÄʵÀý¶¼ÎÞ·¨·ÃÎÊ¡£
»¹ÊÇÏÈ¿´´úÂ룺
&nbs ......
iconvº¯Êý¿âÄܹ»Íê³É¸÷ÖÖ×Ö·û¼¯¼äµÄת»»£¬ÊÇphp±à³ÌÖв»¿ÉȱÉٵĻù´¡º¯Êý¿â¡£
1¡¢ÏÂÔØlibiconvº¯Êý¿âhttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz£»
2¡¢½âѹËõtar -zxvf libiconv-1.9.2.tar.gz;
3¡¢°²×°libiconv
££configure --prefix=/usr/local/iconv
#make
#make install
4¡¢ÖØÐ±àÒëphp Ô ......
.$dbhost = 'localhost';
$dbuser = 'root'; //ÄãµÄmysqlÓû§Ãû
$dbpass = '123456'; //ÄãµÄmysqlÃÜÂë
$dbname = 'data'; //ÄãµÄmysql¿âÃû
//Á¬½Ó±¾µØÊý¾Ý¿â
$GLOBALS["conn"] = mysql_connect($dbhost,$dbuser,$dbpass);
//´ò¿ªÊý¾Ý¿â
mysql_select ......