²»´íµÄphp·Ö²¼Àà
<?php
function genpage(&$sql,$page_size=10)
{
global $pages,$sums,$eachpage,$page; //×ÜÒ³Êý£¬×ܼǼ£¬Ã¿Ò³Êý£¬µ±Ç°Ò³
$page = $_GET["page"];
if($page ==0)$page =1;
$eachpage = $page_size;
$pagesql = strstr($sql," from ");
$pagesql = "select count(*) as ids ".$pagesql;
$conn = mysql_query($pagesql) or die(mysql_error());
if($rs = mysql_fetch_array($conn))$sums = $rs[0];
$pages=ceil($sums/$eachpage);
if($pages==0)$pages=1;
$startpos = ($page-1)*$eachpage;
$sql .=" limit $startpos,$eachpage ";
}
//ÏÔʾ·ÖÒ³
function showpage()
{
global $pages,$sums,$eachpage,$page; //×ÜÒ³Êý£¬×ܼǼ£¬Ã¿Ò³Êý£¬µ±Ç°Ò³£¬ÆäËü²ÎÊý
$link=$_SERVER['PHP_SELF'];
echo "¼Ç¼".$sums.":".$eachpage."¡¡";
echo "Ò³Êý".$page."/".$pages."¡¡";
$p_head=$page-5;
if($p_head<=0)$p_head=1; //Ò³ÂëÑ»·¿ªÊ¼Êý Ç°5¸ö
$p_end=$page+5;
if($p_end>$pages)$p_end=$pages; //Ò³ÂëÑ»·½áÊøÊý ºó5¸ö
echo "[<a href=$link?page=1>Ê×Ò³</a>] ";
for($i=$p_head;$i<=$p_end;$i++)
{
if($i!=$page)
echo "<a href=$link?page=$i>[$i]</a> ";
else
echo "<b><strike>[$i]</strike></b> ";
}
echo " [<a href=$link?page=$pages>Ä©Ò³</a>]";
}
?>
Ïà¹ØÎĵµ£º
cookieĬÈϲ»ÄÜ´æÊý×飬ËùÒÔÏÂÃæµÄд·¨ÊÇ´íÎóµÄ¡£
<?php
$arr = array(1,2,3);
setcookie('a',$arr);
$arr = array(1,2,3);
setcookie('a',$arr);
?>
±¨´íÈçÏ£º
Warning: setcookie() expects parameter 2 to be string, array given in
µ«ÊÇPHP¿ÉÒÔ°ÑͬÃûÇÒºóÃæÒÔ[]½áβµÄcookie½âÎöΪÊý×é¡£ÔÚ ......
¾¡Á¿Ê¹Óõ¥ÒýºÅ¶ø²»ÊÇË«ÒýºÅ¡£
¾¡Á¿Ê¹ÓôøÌõ¼þµÄinclude¶ø²»ÊÇrequire¡£
¾¡Á¿Ê¹ÓÃecho¶ø²»ÊÇprint¡£
¾¡Á¿Ê¹ÓÃÄÚǶµÄHTML¶ø²»ÊÇecho¡£
¾¡Á¿Ê¹ÓÃstr£replace()¶ø²»ÊÇereg£replace()¡£
¾¡Á¿sql²»ÓÃÁªºÏ²éѯ¡£
......
javaµÄд·¨
/**
*
* @param location
* @param nameList±£´æ½á¹ûµÄ£¡
*/
public void listDict(String location, List<String> nameList) {
File fileList = new File(location);
if (fileList.isDirectory()) {
File[] files = fileList.listFiles();
for (File f : files) {
i ......
·þÎñÆ÷±äÁ¿ $_SERVER Ïê½â£º
1¡¢$_SESSION['PHP_SELF'] -- »ñÈ¡µ±Ç°ÕýÔÚÖ´Ðнű¾µÄÎļþÃû
2¡¢$_SERVER['SERVER_PROTOCOL'] -- ÇëÇóÒ³ÃæʱͨÐÅÐÒéµÄÃû³ÆºÍ°æ±¾¡£ÀýÈ磬“HTTP/1.0”¡£
3¡¢$_SERVER['REQUEST_TIME'] -- ÇëÇó¿ªÊ¼Ê±µÄʱ¼ä´Á¡£´Ó PHP 5.1.0 ÆðÓÐЧ¡£ºÍtimeº¯ÊýЧ¹ûÒ»Ñù¡£
4¡¢$_SERVER['argv'] - ......
PHP ÖÐÇÉÓÃÊý×é½µµÍ³ÌÐòµÄʱ¼ä¸´ÔÓ¶È
±¾ÎÄÖ÷ÒªÊǽéÉÜÔÚ PHP µÄ±à³ÌÖУ¬ÈçºÎÇÉÓÃÊý×éÀ´½µµÍÒò¶à²ãÑ»·¶øÒýÆðµÄʱ¼ä¸´ÔӶȵÄÎÊÌâ¡£ÌرðÊǵ±³ÌÐòÐèÒª¶à´ÎÓëÊý¾Ý¿â½»»¥Ê±£¬Óô˷½·¨À´ÓÅ»¯ÄãµÄ´úÂ룬½«»á´ø¸øÒâÏë²»µ½µÄЧ¹û¡£
ͨ³£¿ª·¢ÈËÔ±ÔÚд³ÌÐòµÄʱºò£¬ÍùÍùÊÇ°ÑÒѾÉè¼ÆºÃ»òÕß¹¹Ë¼ºÃµÄÔËËãÂß¼£ ......