phpѧϰ֪ʶµã
1.call_user_func º¯ÊýÀàËÆÓÚÒ»ÖÖÌØ±ðµÄµ÷Óú¯ÊýµÄ·½·¨£¬Ê¹Ó÷½·¨ÈçÏÂ:
function a($b,$c)
{
echo $b;
echo $c;
}
call_user_func('a','111','222');
call_user_func('a','333','444');
//ÏÔʾ111222333444
µ÷ÓÃÀàÄÚ²¿µÄ·½·¨±È½ÏÆæ¹Ö£¬ÓõÄÊÇarray,Óëphp5µÄ¾²Ì¬·½·¨Ïàͬ£¬¼´µÈͬÓÚclass:function
class a{
function b($c){
echo $c;
}
}
call_user_func(array("a","b"),"1111");
//Êä³ö1111
2.array_fill()º¯Êý½«¸øº¯Êý¸³ÉÏÄãËùÉ趨µÄÖµ¡£
Example:
$a=array_fill(2,3,"Dog");
print_r($a);
//Êä³ö½á¹û:Array ( [2] => Dog [3] => Dog [4] => Dog )
3.µÑ¿¨¶û»ýËã·¨:
$a[0] = array(1, 2, 3, 4);
$a[1] = array(5, 6, 7);
$a[2] = array(8, 9);
$index = array_fill(0, count($a), 0);
while ($index[0] < count($a[0])) {
$temp = '';
for ($i = 0; $i < count($index); ++$i) {
$temp .= $a[$i][$index[$i]];
}
echo $temp, '<br/>';
++$index[count($index) - 1];
for ($i = count($index) - 1; $i > 0; --$i) {
if ($index[$i] >= count($a[$i])) {
$index[$i] = 0;
++$index[$i - 1];
}
}
}
4.phpÖвÙ×÷XMLÎļþ
$xml = '<news><item id="1"><title>Item1</title></item><item
id="2"><title>Item2</title></item></news>';
$doc = new DOMDocument();
$doc->loadXML($xml);
foreach($doc->getElementsByTagName('item') as $item)
{
$item->setIdAttribute('id', true);
}
echo $doc->getElementById('1')->childNodes->item(0)->nodeValue;//Item1
5.mysql_escape_string
$user = mysql_escape_string($_GET['user']);
mysql_escape_string:תÒåÒ»¸ö×Ö·û´
Ïà¹ØÎĵµ£º
Ò»¡¢¿´Êֲᣬ¿´ÊֲᣬÊÖ²á²ÅÊÇÍõµÀ£¬http://www.sphinxsearch.com/wiki/doku.php?id=sphinx_chinese_tutorial
¶þ¡¢±ÊÕß½¨Òé²ÉÓÃSphinxSE£¬²¿Êð·½±ã¼òµ¥£¬³ÌÐò¸Ä¶¯½ÏС£¬»ù±¾Ö÷Òª¸ü¸ÄsqlÓï¾ä¼´¿É
Èý¡¢Öصã˵Ã÷£º
1¡¢Èç¹ûÒªËÑË÷ÖÐÎÄ£¬ÔòÐèÔÚÅäÖÃÎļþconfÀïÖ¸¶¨×Ö·û²ÎÊý£¬eg£º
charset_table = U+FF10..U+FF19->0..9, ......
//1. Óû§ÃÜÂëÁùλÊý,²»ÄÜ´óÓÚÁùλ¶ø²»ÄÜСÓÚÁùÊý,Êý×ÖÖµÕýÔòΪ[0-9],ÇëÓÃPHPд³öÓм¸ÖÖ¿ÉÄÜÐÔ,²¢×ö±©Á¦ÆÆ½â;
function dePassword($pwd) {
$tmp = array('000000', '555555', '999999');
for ($i = 0; $i < 3; $i++) {
if ($pwd == $tmp[$i]) return $tmp[$i];
}
return $pwd < $tmp[1] ? getPwd(0, $pwd ......
ÈÏʶORMÆäʵ×îÔçÔ´×ÔÒ»³¡ÕùÂÛ£¬¸÷¸ö¿ò¼Ü¶¼Éù³Æ¾ß±¸Á¼ºÃµÄORMʵÏÖ£¬µ«ÊÇʹ
Óúó·¢ÏÖ£¬Èç¹û½ö½öÊÇÇ¿ÖÆ·µ»ØÊý¾Ý¶ÔÏó»¹Éù³Æ×Ô¼ºÊÇORMµÄ»°£¬ÄǾÍêÝЦ´ó·½ÁË¡£ÄÇÖ»ÄÜ˵ÊÇαORM»òÊÇORA£¨array£©¶øÒÑ¡£ºÜÏÔÈ»·µ»ØµÄ¶ÔÏó³ýÁË
ÊôÐÔÖµÍ⣬»¹Ó¦¸Ã°üÀ¨¿ÉÖ´Ðз½·¨£¬ÊµÏÖ¶ÔÊý¾ÝµÄ²Ù×÷ÔËÓá£
ºóÀ´¹¤×÷¸ÄÓÃsymfony
¿ò¼Ü£¬¸Ã¿ò¼ÜÄÚÖÃÁ˶ ......
±íµ¥ºÍÓû§ÊäÈë
PHP ±íµ¥´¦Àí
±íµ¥ÊµÀý£º
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name" />
Age: <input type="text" name="age" />
<input type="submit" />
</form>
</body>
</html> ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/02/1-9/
PHPÖÐIncludeÓï¾äÔÚÓ÷¨ÉϺÍrequireÓï¾ä»ù±¾Ïàͬ£¬µ«ÊÇËûÃÇ»¹´æÔÚÁ½µã²îÒ죺
»úÖÆ²»Í¬
RequireÓï¾äÔÚ½øÐÐÎļþ°üº¬Ê±£¬²»¹ÜÕâÌõrequireÓï¾äÊÇ·ñ±»ÔËÐУ¬¶¼»á½«±»°üº¬´úÂëÖеÄÎļþ°üº¬½øÀ´¡£
IncludeÓï¾äÔÚ½øÐÐÎļþ°ü ......