Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Îå¸ö³£¼û PHP Êý¾Ý¿âÎÊÌâ

Èç¹ûÖ»ÓÐÒ»ÖÖ ·½Ê½Ê¹ÓÃÊý¾Ý¿âÊÇÕýÈ·µÄ……
Äú¿ÉÒÔÓúܶàµÄ·½Ê½´´½¨Êý¾Ý¿âÉè¼Æ¡¢Êý¾Ý¿â·ÃÎʺͻùÓÚÊý¾Ý¿âµÄ PHP ÒµÎñÂß¼­´úÂ룬µ«×îÖÕÒ»°ãÒÔ´íÎó¸æÖÕ¡£±¾ÎÄ˵Ã÷ÁËÊý¾Ý¿âÉè¼ÆºÍ·ÃÎÊÊý¾Ý¿âµÄ PHP ´úÂëÖгöÏÖµÄÎå¸ö³£¼ûÎÊÌ⣬ÒÔ¼°ÔÚÓöµ½ÕâЩÎÊÌâʱÈçºÎÐÞ¸´ËüÃÇ¡£
ÎÊÌâ 1£ºÖ±½ÓʹÓà MySQL
Ò»¸ö³£¼ûÎÊÌâÊǽÏÀ쵀 PHP ´úÂëÖ±½ÓʹÓà mysql_ º¯ÊýÀ´·ÃÎÊÊý¾Ý¿â¡£Çåµ¥ 1 չʾÁËÈçºÎÖ±½Ó·ÃÎÊÊý¾Ý¿â¡£
Çåµ¥ 1. Access/get.php
<?php
function get_user_id( $name )
{
$db = mysql_connect( 'localhost', 'root', 'password' );
mysql_select_db( 'users' );
$res = mysql_query( "SELECT id from users WHERE login='".$name."'" );
while( $row = mysql_fetch_array( $res ) ) { $id = $row[0]; }
return $id;
}
var_dump( get_user_id( 'jack' ) );
?>
×¢ÒâʹÓÃÁË mysql_connect º¯ÊýÀ´·ÃÎÊÊý¾Ý¿â¡£»¹Òª×¢Òâ²éѯ£¬ÆäÖÐʹÓÃ×Ö·û´®Á¬½ÓÀ´Ïò²éѯÌí¼Ó $name ²ÎÊý¡£
¸Ã¼¼ÊõÓÐÁ½¸öºÜºÃµÄÌæ´ú·½°¸£ºPEAR DB Ä£¿éºÍ PHP Data Objects (PDO) Àà¡£Á½Õ߶¼´ÓÌض¨Êý¾Ý¿âÑ¡ÔñÌṩ³éÏó¡£Òò´Ë£¬ÄúµÄ´úÂëÎÞÐèÌ«¶àµ÷Õû¾Í¿ÉÒÔÔÚ IBM® DB2®¡¢MySQL¡¢PostgreSQL »òÕßÄúÏëÒªÁ¬½Óµ½µÄÈκÎÆäËûÊý¾Ý¿âÉÏÔËÐС£
ʹÓà PEAR DB Ä£¿éºÍ PDO ³éÏó²ãµÄÁíÒ»¸ö¼ÛÖµÔÚÓÚÄú¿ÉÒÔÔÚ SQL Óï¾äÖÐʹÓà ? ²Ù×÷·û¡£ÕâÑù×ö¿Éʹ SQL ¸ü¼ÓÒ×ÓÚά»¤£¬ÇÒ¿ÉʹÄúµÄÓ¦ÓóÌÐòÃâÊÜ SQL ×¢Èë¹¥»÷¡£
ʹÓà PEAR DB µÄÌæ´ú´úÂëÈçÏÂËùʾ¡£
Çåµ¥ 2. Access/get_good.php
<?php
require_once("DB.php");
function get_user_id( $name )
{
$dsn = 'mysql://root:password@localhost/users';
$db =& DB::Connect( $dsn, array() );
if (PEAR::isError($db)) { die($db->getMessage()); }
$res = $db->query( 'SELECT id from users WHERE login=?',
array( $name ) );
$id = null;
while( $res->fetchInto( $row ) ) { $id = $row[0]; }
return $id;
}
var_dump( get_user_id( 'jack' ) );
?>
×¢Ò⣬ËùÓÐÖ±½ÓÓõ½ MySQL µÄµØ·½¶¼Ïû³ýÁË£¬Ö»ÓÐ $dsn ÖеÄÊý¾Ý¿âÁ¬½Ó×Ö·û´®³ýÍâ¡£´ËÍ⣬ÎÒÃÇͨ¹ý ? ²Ù×÷·ûÔÚ SQL ÖÐʹÓà $name ±äÁ¿¡£È»ºó£¬²éѯµÄÊý¾Ýͨ¹ý query() ·½·¨Ä©Î²µÄ array ±»·¢ËͽøÀ´¡£
ÎÊÌâ 2£º²»Ê¹ÓÃ×Ô¶¯ÔöÁ¿¹¦ÄÜ
Óë´ó¶àÊýÏÖ´úÊý¾Ý¿âÒ»Ñù£¬MySQL Äܹ»ÔÚÿ¼Ç¼µÄ»ù´¡ÉÏ´´½¨×Ô¶¯ÔöÁ¿Î©Ò»±êʶ·û¡£³ý´ËÖ®Í⣬Î


Ïà¹ØÎĵµ£º

PHPѧϰ֮ PHP ×Ö·û´®

×Ö·û´®±äÁ¿ÓÃÓÚ´æ´¢²¢´¦ÀíÎı¾Æ¬¶Î¡£
PHP ÖеÄ×Ö·û´®
×Ö·û´®±äÁ¿ÓÃÓÚ°üº¬×Ö·û´®µÄÖµ¡£
ÔÚ±¾½Ì³ÌÖУ¬ÎÒÃÇ´òËã½éÉܼ¸¸öÔÚ PHP ÖÐÓÃÓÚ²Ù×÷×Ö·û´®µÄ×î³£Óõĺ¯ÊýºÍÔËËã·û¡£
ÔÚ´´½¨×Ö·û´®Ö®ºó£¬ÎÒÃǾͿÉÒÔ¶ÔËü½øÐвÙ×÷ÁË¡£Äú¿ÉÒÔÖ±½ÓÔÚº¯ÊýÖÐʹÓÃ×Ö·û´®£¬»òÕß°ÑËü´æ´¢ÔÚ±äÁ¿ÖС£
ÔÚÏÂÃ棬PHP ½Å±¾°Ñ×Ö·û´® "Hello World" ¸³ ......

PHPѧϰ֮ PHP ÔËËã·û


ÔËËã·ûÓÃÓÚ¶ÔÖµ½øÐÐÔËËã.
PHP ÔËËã·û
±¾²¿·ÖÁгöÁËÔÚ PHP ÖÐʹÓõĸ÷ÖÖÔËËã·û£º
ËãÊýÔËËã·û
ÔËËã·û˵Ã÷Àý×Ó½á¹û
+
Addition
x=2
x+2
4
-
Subtraction
x=2
5-x
3
*
Multiplication
x=4
x*5
20
/
Division
15/5
5/2
3
2.5
%
Modulus (division remainder)
5%2
10%8
10%2
1
2
0
++
Incre ......

1·ÖÖÓÍêÃÀ°²×°×îРCentOS + Nginx + PHP FPM + MySQL


PHP 5.3.1
MySQL 5.0.89
Nginx 0.8.33 »ò 0.7.65 £¨¿ÉÑ¡£©
ÏÖÔÚ£¬ÎÒÃÇ¿ÉÒÔ¿ìËÙÈ«×Ô¶¯¸ã¶¨ CentOS + Nginx + PHP-FPM + MySQL µÄ°²×°ÁË
Õâ¸ö¿É±ÈÍøÉÏÁ÷´«µÄʲôһ¼ü°²×°°üÒªºÃµÃ¶à£¬Ç¿ÁÒÍƼö´Ë·¨°²×°£¬ÊʺÏËùÓвËÄñºÍ¸ßÊÖ
ÎÒ·þÎñÆ÷ÉÏÈ«ÓõÄÔ´ ......

PHPÈýÖÖ³£Óÿò¼ÜZend¡¢symfony ºÍ CakePHP

Ä£ÐÍ¿ò¼Ü
¿ò¼Ü˼Ïë¾ÍÊÇÌṩһÖÖ¿ÉÒÔÔÚ¶à¸öÓ¦ÓóÌÐòÖÐʹÓõÄÉè¼Æ¡£ËùÓÐÓ¦ÓóÌÐò¶¼ÓдóÁ¿Í¨ÓõĻù±¾ÄÚÈÝ —— ¾ßÌåµØ˵£¬¾ÍÊÇijÀàÓëÊý¾Ý¿âµÄ½Ó¿Ú¡¢Ä³Ð©Ó¦ÓóÌÐòÂß¼­¡¢Ó¦ÓóÌÐò³ÊÏÖ¸øÓû§µÄÄÚÈݵȡ£Èç¹ûÄú±àд¹ýÐí¶à PHP Ó¦ÓóÌÐò£¬Ôò»áÖªµÀÕâЩ»ù±¾ÄÚÈÝÊÇʲô¡£Äú¿ÉÄÜÒѾ­±àд¹ýÒ»×麯Êý»ò´ÓÊý¾Ý¿âÖжÁÈ¡Êý¾ÝºÍÏòÊ ......

±àд°²È« PHP Ó¦ÓóÌÐòµÄÆ߸öÏ°¹ß

ÔÚÌá¼°°²È«ÐÔÎÊÌâʱ£¬ÐèҪעÒ⣬³ýÁËʵ¼ÊµÄƽ̨ºÍ²Ù×÷ϵͳ°²È«ÐÔÎÊÌâÖ®Í⣬Äú»¹ÐèҪȷ±£±àд°²È«µÄÓ¦ÓóÌÐò¡£ÔÚ±àд PHP Ó¦ÓóÌÐòʱ£¬ÇëÓ¦ÓÃÏÂÃæµÄÆ߸öÏ°¹ßÒÔÈ·±£Ó¦ÓóÌÐò¾ßÓÐ×îºÃµÄ°²È«ÐÔ£º
ÑéÖ¤ÊäÈë
±£»¤Îļþϵͳ
±£»¤Êý¾Ý¿â
±£»¤»á»°Êý¾Ý
±£»¤¿çÕ¾µã½Å±¾£¨Cross-site scripting£¬XSS£©Â©¶´
¼ìÑé±íµ¥ post
Õ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ