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:תÒåÒ»¸ö×Ö·û´
Ïà¹ØÎĵµ£º
¼ÙÉèphp°²×°ÔÚ/usr/local/php5/bin/php£¬³õʼÔÚÃüÁîÐÐÖ´ÐÐPHPµÄʱºòÒªÊäÈëÒ»³¤´®µÄ·¾¶£¬eg£º
$>/usr/local/php5/bin/php phpinfo.php
·Ç³£µÄÂé·³£¬ÏÖÔÚÖ»Ð轫php¿½±´ÖÁusr/sbinĿ¼¼´¿ÉÖ±½ÓʹÓÃphpÃüÁeg£º
$>cp /usr/local/php5/bin/php /usr/sbin/
$>php phpinfo.php
......
¹úÍâÔ½À´Ô½¶àµÄ¹«Ë¾¿ª·¢FacebookÓ¦Óã¬ÖÁÓÚ¹úÄÚÔÝÇÒ²»±í£¬´ó¼ÒÐÄÖª¶ÇÃ÷¡£»¹ºÃHKÒ²ËãÊÇÌ쳯ϽÇø£¬±¾ßÖÐÒ²Ëã´øÓаëÏ´¾ß……¿ª·¢Á˼¸¿îFacebookÓ¦Óã¬×ܽá¾Ñé½Ìѵ£¬ÔÚÒµÓàʱ¼ä¿ª·¢ÁËÒ»¿îFacebookÓ¦ÓÃPHP¿ª·¢¿ò¼Ü——Fabos¡£
Ϊɶ½ÐFabos£¿ÎÒÓÐÒ»¸öfabosÓòÃû£¬±»ºÍг£¡¾ÍËã×ö¸ö¼ÍÄҲµ±×öÊÇÒµÓàʱ¼ä ......
//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 ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/02/02/1-9/
PHPÖÐIncludeÓï¾äÔÚÓ÷¨ÉϺÍrequireÓï¾ä»ù±¾Ïàͬ£¬µ«ÊÇËûÃÇ»¹´æÔÚÁ½µã²îÒ죺
»úÖƲ»Í¬
RequireÓï¾äÔÚ½øÐÐÎļþ°üº¬Ê±£¬²»¹ÜÕâÌõrequireÓï¾äÊÇ·ñ±»ÔËÐУ¬¶¼»á½«±»°üº¬´úÂëÖеÄÎļþ°üº¬½øÀ´¡£
IncludeÓï¾äÔÚ½øÐÐÎļþ°ü ......