PHPÊý×éµÄ×ܽá
Ò»¡¢Ê²Ã´ÊÇÊý×é
Êý×é¾ÍÊÇÒ»×éÊý¾ÝµÄ¼¯ºÏ£¬°ÑһϵÁÐÊý¾Ý×éÖ¯ÆðÀ´£¬ÐγÉÒ»¸ö¿É²Ù×÷µÄÕûÌå¡£Êý×éµÄÿ¸öʵÌ嶼°üº¬Á½Ï¼üºÍÖµ¡£
¶þ¡¢ÉùÃ÷Êý¾Ý
ÔÚPHPÖÐÉùÃ÷Êý×éµÄ·½Ê½Ö÷ÒªÓÐÁ½ÖÖ£ºÒ»ÊÇÓ¦ÓÃarray()º¯ÊýÉùÃ÷Êý×飬һÊÇÖ±½ÓΪÊý×éÔªËظ³Öµ¡£
<1>array()º¯ÊýÉùÃ÷µÄÊý×éµÄ·½Ê½array([mixed...]) ²ÎÊýmixedµÄÓ﷨Ϊkey=>value
È磬<?php
$array=array("1"=>"±à","2"=>"³Ì","3"=>"´Ê","4"=>"µä");
print_r($array);
echo "<br>";
echo $array[1]; //×¢Ò⣺ϱêĬÈÏÊÇ´Ó0¿ªÊ¼
echo $array[2];
echo $array[3];
echo $array[4];
?>
<2>Ö±½ÓΪÊý×éÔªËظ³Öµ¡£Èç¹ûÔÚ´´½¨Êý×éʱ²»ÖªËù´´½¨Êý×éµÄ´óС£¬»òÔÚʵ¼Ê±àд³ÌÐòʱÊý×éµÄ´óС¿ÉÄÜ·¢Éú±ä»¯£¬²ÉÓÃÕâÖÖÊý×é´´½¨µÄ·½·¨½ÏºÃ¡£
È磬<?php
$array[1]="I";
$array[2]="love";
$array[3]="PHP";
print_r($array); //Êä³öËù´´½¨Êý×éµÄ½á¹¹
?>
Èý¡¢Êý×éµÄÀàÐÍ
PHPÖ§³ÖÁ½ÖÖÊý×飺Ë÷ÒýÊý×é(indexed array)ºÍÁªºÏÊý×é(associative array)£¬Ç°ÕßʹÓÃÊý×Ö×÷Ϊ¼ü£¬ºóÕßʹÓÃ×Ö·û´®×÷Ϊ¼ü¡£
ËÄ¡¢Êä³öÊý×é
ÔÚPHPÖжÔÊý×éÔªËØÊä³ö£¬¿ÉÒÔͨ¹ýechoºÍprintÓï¾äÀ´ÊµÏÖ£¬µ«ÕâÖ»ÄܶÔÊý×éÖÐijһԪËؽøÐÐÊä³ö£»Òª½«Êý×é½á¹¹Êä³öÔòҪʹÓÃprint_r()º¯
Êý£¬ÆäÓï·¨£ºprint_r(mixed
expression),²ÎÊýexpressionΪÆÕͨµÄÕûÐΡ¢×Ö·ûÐÍ»òʵÐͱäÁ¿ÔòÊä³ö¸Ã±äÁ¿±¾Éí£¬Èç¹û¸Ã²ÎÊýΪÊý×飬Ôò°´Ò»¶¨¼üÖµºÍÔªËصÄ˳ÐòÏÔʾ³ö
¸ÃÊý×éÖеÄËùÓÐÔªËØ¡£
Îå¡¢Êý×éµÄ¹¹Ôì
һάÊý×飺
µ±Ò»¸öÊý×éµÄÔªËØÊDZäÁ¿Ê±£¬Ôò³ÆÆäΪһάÊý×é¡£
ÉùÃ÷һλÊý×飺 ÀàÐÍ˵Ã÷·û Êý×éÃû[³£Á¿±í´ïʽ]£»
¶þάÊý×飺
µ±Ò»¸öÊý×éµÄÔªËØÊÇÒ»¸öһλÊý×éʱ£¬Ôò³Æ֮Ϊ¶þάÊý×é¡£
È磬<?php
$str = array (
"ÍøÂç±à³ÌÓïÑÔ"=>array ("PHP","JSP","ASP"),
"ÌåÓýÏîÄ¿"=>array ("m"=>"×ãÇò","n"=>"ÀºÇò"));
print_r ( $str) ;
?>
Áù¡¢±éÀúÊý×é
±éÀ
Ïà¹ØÎĵµ£º
ÕâÀï½éÉÜÒ»¸ö¼¯³É»·¾³ XAMPP¡£
XAMPP ÊÇÒ»¸öÒ×ÓÚ°²×°ÇÒ°üº¬ MySQL¡¢PHP ºÍ Perl µÄ Apache ·¢Ðа档XAMPP µÄÈ··Ç³£ÈÝÒ×°²×°ºÍʹÓãºÖ»ÐèÏÂÔØ£¬½âѹËõ£¬Æô¶¯¼´¿É¡£
ÏÂÔصØÖ·£º
http://www.apachefriends.org/zh_cn/xampp.html
µ½Ä¿Ç°ÎªÖ¹£¬XAMPP ¹²ÓÐÒÔÏÂËÄÖÖ°æ±¾£º
£¨1£©ÊÊÓÃÓÚ Linux µÄ XAMPP
£¨2£©ÊÊÓÃÓÚ Windows µ ......
PHPÊǸöΰ´óµÄweb¿ª·¢ÓïÑÔ£¬Áé»îµÄÓïÑÔ£¬µ«ÊÇ¿´µ½php³ÌÐòÔ±Öܶø¸´Ê¼µÄ·¸µÄһЩ´íÎó¡£ÎÒ×öÁËÏÂÃæÕâ¸öÁÐ±í£¬ÁгöÁËPHP³ÌÐòÔ±¾³£·¸µÄ10ÖдíÎ󣬴ó¶àÊýºÍ°²È«Ïà¹Ø¡£¿´¿´Äã·¸Á˼¸ÖÖ
1.²»×ªÒâhtml entities
Ò»¸ö»ù±¾µÄ³£Ê¶£ºËùÓв»¿ÉÐÅÈεÄÊäÈ루ÌرðÊÇÓû§´ÓformÖÐÌá½»µÄÊý¾Ý£© £¬Êä³ö֮ǰ¶¼Òª×ªÒâ¡£
echo $ ......
UbuntuÎÞÒÉÊÇlinux³õѧÕßµÄÊ×Ñ¡°æ±¾£¬ÒòΪËüͼÐνçÃæÖ§³ÖµÄ·Ç³£ºÃ¡£
È»¶øxammpÊÇphp³õѧÕßµÄÊ×Ñ¡¡£
1.ʲôÊÇxammp?
XAMPP£¨Apache+MySQL+PHP+PERL£©ÊÇÒ»¸ö¹¦ÄÜÇ¿´óµÄ½¨Õ¾¼¯³ÉÈí¼þ°ü¡£Õâ¸öÈí¼þ°üÔÀ´µÄÃû×ÖÊÇLAMPP£¬µ«ÊÇΪÁ˱ÜÃâÎó½â£¬×îеļ¸¸ö°æ±¾¾Í¸ÄÃûΪ XAMPP ÁË¡£Ëü¿ÉÒÔÔÚWindows¡¢Linux¡¢SolarisÈýÖÖ²Ù×÷ϵͳÏ°² ......
ÎÒ´òËãÔÚÃüÁîÐÐÖÐÕâÑùµ÷ÓÃphp£º cat filename|php a.php£¬ÈÃa.php¶ÁÈ¡filenameÀïÃæµÄÿÐмǼ½øÐд¦Àí£¬·½·¨ÈçÏ£º
<?php
$fp = fopen("/dev/stdin", "r");
while($input = fgets($fp, 10000))
{
echo urldecode($input);
}
?>
......
<?php
/**
* Mysql DB
*
* @author Administrator
* @package defaultPackage
*/
class MySqlDB{
private $_db;
private static $_instance;
private function __construct(&$db_type){
global $connectionstr;
$conn_db=$connectionstr[$db_type];
$this->_db=mysql_pconnect($conn ......