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

PHP ·ÖÒ³


·ÂGOOGLEºÍDiscuz·ÖÒ³º¯Êý(php)
Õâ¸öº¯ÊýÖ»ÐèÒª2¸ö²ÎÊý µ±Ç°Ò³ÂëºÍ×ÜÒ³Êý,$siteÊÇ·¾¶,ÎļþÃû¿ÉÒÔ°´×Ô¼ºµÄÐèÒªÐÞ¸Ä
Õâ¸öº¯Êý²»ÄÜ´«µÝÆäËû²ÎÊý,Èç¹ûÒª´«µÝÆäËû²ÎÊý,ÔÚº¯ÊýÀï×Ô¼º¼ÓÒ»¸ö²ÎÊý¾ÍÐÐÁË
<?php
//¼ÆÊý
$sql = “SELECT count(*) from `andycms_title`;”;
$numrs = mysql_query($sql) or die(mysql_error());
$numrow = mysql_fetch_row($numrs);
$num = $numrow[0]; //×ܼǼ
$total = ceil($num / $perpage); //×ÜÒ³Êý
//µ±Ç°Ò³Âë
if(!isset($_GET[‘page’]) preg_match(‘~[^0-9]+~’,($_GET[‘page’])) $_GET[‘page’] <= 0 $_GET[‘page’] > $total) $page = 1;
else $page = $_GET[‘page’];
$startnum = ($page-1) * $perpage; //¼Ç¼¼¯¿ªÊ¼Êý
?>
<?php
// Andy·ÖÒ³º¯Êý
function fenye ($p,$total)
{
global $site;
$prevs = $p - 10; if ( $prevs <= 0) { $prevs = 1; }
$prev = $prevs - 1; if ( $prev <= 0) {$prev = 1;}
$nexts = $p + 9; if ( $nexts > $total) { $nexts = $total; }
$next = $nexts + 1; if ( $next > $total) {$next = $total;}
$pagenavi = “<a href=\”$site/?page=1\”>Ê×Ò³</a> “;
$pagenavi.= “<a href=\”$site/?page=$prev\”>ÉÏÒ³</a> “;
for ( $i = $prevs; $i <= $p-1; $i++ ) {
$pagenavi.= “<a href=\”$site/?page=$i\”>$i</a> “;
}
$pagenavi.= “<strong>$p</strong> “;
for ( $i = $p+1; $i <= $nexts; $i++ ) {
$pagenavi.= “<a href=\”$site/?page=$i\”>$i</a> “;
}
$pagenavi.= “<a href=\”$site/?page=$next\”>ÏÂÒ³</a> “;
$pagenavi.= “<a href=\”$site/?page=$total\”>βҳ</a> “;
return $pagenavi;
}
?>
Ч¹û:
page=1
Ê×Ò³ ÉÏÒ³ 1 2 3 4 5 6 7 8 9 10 ÏÂÒ³ βҳ
page=10
Ê×Ò³ ÉÏÒ³ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 ÏÂÒ³ βҳ
page=20
Ê×Ò³ ÉÏÒ³ 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27


Ïà¹ØÎĵµ£º

PHPÕýÔò±í´ïʽº¯Êý

ÕýÔò±í´ïʽ×Ô¼ºÒ»Ö±²»ÊìϤ£¬Õâ2ÌìÔÚÍøÉÏÒ»Ö±¿´¹ØÓÚËüµÄÎÄÕ£¬×Ô¼º×ܽáÁ˼¸¸öº¯Êý¡£
1£®preg_match()
º¯ÊýÔ­ÐÍ£ºint preg_match (string $pattern, string $content [, array
$matches])
preg_match
()º¯ÊýÔÚ$content×Ö·û´®ÖÐËÑË÷Óë$pattern¸ø³öµÄÕýÔò±í´ïʽÏàÆ¥ÅäµÄÄÚÈÝ¡£Èç¹ûÌṩÁË$matches£¬Ôò½«Æ¥Åä½á¹û·ÅÈëÆäÖС ......

PHPº¯ÊýeregÓëpregµÄÇø±ð

      1¡¢eregÀïÃæÊDz»ÐèÒªÒ²²»ÄÜʹÓ÷ָô·ûºÍÐÞÊηûµÄ£¬ËùÒÔeregµÄ¹¦ÄܱÈpregÒªÈõÉϲ»ÉÙ¡£
¡¡¡¡2¡¢¹ØÓÚ"."£ºµãÔÚÕýÔòÀïÃæÒ»°ãÊdzýÁË»»ÐзûÒÔÍâµÄÈ«²¿×Ö·û£¬µ«ÊÇÔÚeregÀïÃæµÄ"."ÊÇÈÎÒâ×Ö·û£¬¼´°üÀ¨»»Ðзû£¡Èç¹ûÔÚpregÀïÃæÏ£Íû"."
Äܹ»°üÀ¨»»Ðзû£¬¿ÉÒÔÔÚÐÞÊηûÖÐ ......

phpץȡalexaÍøÒ³ÄÚÈÝ Ìáȡվµãͳ¼ÆÐÅÏ¢

ÈÎÎñ£º¸ù¾ÝÊäÈëµÄÓòÃû ͳ¼ÆÒÔÏÂÈý¸öÊý¾Ý£¬µÚÒ»£ºÈ«ÇòÅÅÃû£»µÚ¶þ£ºÓû§Á¿£¨ÔÂÆ½¾ùÖµ£©£»µÚÈý£º
È˾ùÒ³Ãæ·ÃÎÊÁ¿£¨ÔÂÆ½¾ùÖµ£©¡£
˼·£ºÊ¹ÓÃget_file_contentsÌáÈ¡³öÍøÒ³ÄÚÈÝ£¬ÔÙ¸ù¾ÝÕýÔò±í´ïʽ½øÐÐÄÚÈݵÄɸѡ¡£
ºËÐĺ¯ÊýÈçÏ£º
<?php
/*
 the function of getting aleax data
 @param string partten  ......

phpÖÐʹÓÃheaderº¯ÊýµÄhttpÍ·ÉèÖÃ

/ ok
header('HTTP/1.1 200 OK');
//ÉèÖÃÒ»¸ö404Í·:
header('HTTP/1.1 404 Not Found');
//ÉèÖõØÖ·±»ÓÀ¾ÃµÄÖØ¶¨Ïò
header('HTTP/1.1 301 Moved Permanently');
//תµ½Ò»¸öеØÖ·
header('Location: http://www.example.org/'
);
//ÎļþÑÓ³ÙתÏò:
header('Refresh: 10; url=http://www.example.org/');
print 'Y ......

¡¾´ýÐ޸ġ¿validator±íµ¥ÑéÖ¤ÀàPHP°æ±¾

<?php
/*****************
Ãû³Æ£ºvalidator For PHP v1.0.0
ÈÕÆÚ£º2006-12-7
×÷ÕߣºÎ÷Â¥ÀäÔÂ
꿅᣼www.xilou.net | www.chinaCMS.org
ÃèÊö£ºÊý¾Ý¼ìÑéÀ࣬ÓÃÔÚ±íµ¥ÑéÖ¤ÉÏ
¹æÔò£ºÎÞ
*****************/
/*php×ÔÉíµÄ¼ì²âº¯Êý
*bool is_numeric ( mixed var)
*bool is_bool ( mixed var)
*bool is_null ( mixed ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ