欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php锛媘ysql鎵庡疄涓汉鍩烘湰鍔焈PHP鏁欑▼ | 甯涔嬪

程序员文章站 2024-04-03 14:34:04
...
涓€. 10鍙ヨ瘽
1.涓嶈渚濊禆register_global=ON鐨勭幆澧冿紝浠庝綘鍒氭*寰楅厤缃畃hp杩愯鐜鐢氳嚦灏氫笉鏄庣櫧register_global鐨凮N/OFF浼氬鑷繁鏈変粈涔堝奖鍝嶇殑閭eぉ璧凤紝灏卞簲璇ュ媷鏁㈠湴鎶婂畠璁句负OFF.
2.鍐欑▼搴忓墠鐪嬬湅鎬庝箞鐢╡rror_reporting.
3.涓嶆*灏遍棶鏈韩娌¢敊锛屼絾浣犻渶瑕佸湪閭d箣鍓嶆煡鏌ユ墜鍐屻€?BR>4.褰撶劧锛屼綘闇€瑕佹*寰椾娇鐢ㄦ墜鍐屻€傛墜鍐屼笂鎵句笉鍒扮瓟妗堢殑鏃跺€欙紝搴旇鑰冭檻涓嬬綉缁滀笂鐨勬悳绱㈠紩鎿庛€?BR>5.鍒氬浼歱hp+mysql涔嬪悗锛屼笉瑕佸彨鍤风潃瑕佸啓璁哄潧锛岃鍐橷XX銆傝鏄庣櫧锛屽垰瀛︿細鍐欐眽瀛楀苟涓嶈〃绀轰綘鏈夎兘鍔涘啓璇椼€?BR>6.鍦ㄥweb缂栫▼鐨勬椂鍊欙紝浣犲簲璇ュ厛鍘昏璇唄tml杩欎釜鏈嬪弸銆?BR>7.鏈夌偣鑳藉姏鍚庯紝璇曠潃鍥炵瓟鏂版墜鐨勯棶棰橈紝涓嶈鐪嬪埌鑷繁鎳傜殑鑰屽埆浜轰笉鎳傚氨娌炬簿鑷枩锛屾墧涓嬩竴鍚嶁€滅畝鍗曪紝閭f槸鍩烘湰鐨勪笢瑗库€濆氨璧版洿瑕佷笉寰椼€?BR>8.鎬濊€冩槸涓€涓ソ涔犳儻锛屼笉鍔ㄦ墜鍘诲啓灏辩瓑浜庣┖鎯筹紝浠€涔堜篃娌℃湁銆?BR>9.鍐欏ソ涓€娈电▼搴忥紝濡傛灉瑙夊緱寰堟弧鎰忥紝涓€鍛ㄥ悗鍐嶇湅涓€閬嶏紝涔熻浣犱細璁や负瀹冨簲璇ユ湁鎵€鏀瑰彉
10.鏈夌┖澶氱湅鐪嬪埆浜虹殑绋嬪簭锛屾壘鍑轰粬浜虹殑涓嶈冻鎴栦紭鐐癸紝鑷繁鎺傞噺銆?BR>
浜? 鍚勫彇鎵€闇€

1.鍠勪簬浣跨敤鈥滃紩鐢ㄢ€?瀹冭兘鐩存帴褰卞搷鍒扮▼搴忕殑鏁堢巼銆?BR>
2.鍠勪簬鐢ㄤ笁鍏冭繍绠楀瓙,鍙互璁╃▼寮忚緝绮剧畝鏈夋晥鐜囥€?BR>姣斿:
PHP浠g爜:

if ($data[$i][nickname])
{
$nickname = $data[$i][nickname];
}
else
{
$nickname = $data[$i][ip];
}


鍙互鍐欐垚:

PHP浠g爜:

$nickname = $data[$i][nickname] ? $data[$i][nickname] : $data[$i][ip];



3.鍠勪簬缁勭粐if...else...鍥炲湀
姣斿:

PHP浠g爜:

$ext_name = strtolower(str_replace(".", "", strrchr($upfilename, ".")));
if (!empty($type))
{
if (!strpos($type, $ext_name))
{
echo "Please upload the file of $type form.";
exit();
}
}


涓婇潰鐨勪唬鐮佷綘搴旇鍐欐垚杩欐牱:

PHP浠g爜:

$ext_name = strtolower(str_replace(".", "", strrchr($upfilename, ".")));
if (!($type===) && strpos($type, $ext_name)===false)
{
echo "Please upload the file of $type form.";
exit();
}



4.灏介噺璁╀綘鐨勪唬鐮佹竻娣呬簺
濡傛灉鍐欐垚杩欐牱锛屾槸姣旇緝璁╀汉澶寸棝鐨?

PHP浠g爜:

$foo=$_post["foo"];
$username=$_post["user"];
$group=$_POST["group"];
if ($group=="wheel"){
$username=$username."wheel";
}


鍚屾牱鐨勪唬鐮侊紝杩欐牱灏辨瘮杈冭浜虹湅寰楄垝鏈嶄簡:

PHP浠g爜:

$foo = $_post["foo"];
$username = $_post["username"];
$group = $_POST["group"];
if ($group=="wheel")
{
$username = $username."wheel";
}


褰撶劧锛屾湁涓€瀹氬熀纭€鍚庯紝浣犲簲璇ヨ鍐欐垚杩欐牱:

PHP浠g爜:

$foo = &$_POST[foo];
$username = $_POST["group"]!=wheel ? $_POST["username"] : $_POST["username"].wheel;


5.缂栧啓瑙勮寖鐨刴ysql 璇彞銆?BR>瀛楁鍜岃〃鍚嶇敤"`"寮曡捣鏉ワ紝閬垮厤淇濈暀瀛楃殑褰卞搷銆?BR>濡傛灉鐪嬪埌涓嬮潰杩欐牱鐨勪竴涓猻ql query锛屼細璁╀汉姣旇緝澶寸棝:

PHP浠g爜:

$query="select `flash_comment`.`content` , `flash_comment`.`nickname` , `flash_comment`.`date` , `flash_comment`.`ip` , `product`.`p_name` , `sgflash`.`fid` from `flash_comment` left join `product` on ( `flash_comment`.`p_no` = `product`.`p_no` ) left join `sgflash` on ( `product`.`p_name` = `sgflash`.`f_name` ) where `flash_comment`.`p_no` != order by `flash_comment`.`date`";


鍚屾牱鐨勪竴涓猶uery,鍐欐垚杩欐牱灏变护浜虹湅寰楁槑鐧藉緱澶氫簡:

PHP浠g爜:

$query = "SELECT `flash_comment`.`content` , `flash_comment`.`nickname` , `flash_comment`.`date` , `flash_comment`.`ip` , `product`.`p_name` , `sgflash`.`fid`
FROM `flash_comment`
LEFT JOIN `product` ON ( `flash_comment`.`p_no` = `product`.`p_no` )
LEFT JOIN `sgflash` ON ( `product`.`p_name` = `sgflash`.`f_name` )
WHERE `flash_comment`.`p_no` !=
ORDER BY `flash_comment`.`date`";

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/532436.htmlTechArticle涓€. 10鍙ヨ瘽 1.涓嶈渚濊禆register_global=ON鐨勭幆澧冿紝浠庝綘鍒氭*寰楅厤缃畃hp杩愯鐜鐢氳嚦灏氫笉鏄庣櫧register_global鐨凮N/OFF浼氬鑷繁鏈変粈涔堝奖鍝嶇殑閭eぉ璧凤紝灏卞簲...