PHP header() examples
//ÓÃÕâ¸öheaderÖ¸ÁîÀ´½â¾öURLÖØд²úÉúµÄ404 header
header('HTTP/1.1 200 OK');
// Ò³ÃæûÕÒµ½
header('HTTP/1.1 404 Not Found');
// ·ÃÎÊÊÜÏÞ
header('HTTP/1.1 403 Forbidden');
// The page moved permanently should be used for
// all redrictions, because search engines know
// what's going on and can easily update their urls.
//Ò³Ãæ±»ÓÀ¾Ãɾ³ý£¬¿ÉÒÔ¸æËßËÑË÷ÒýÇæ¸üÐÂËüÃǵÄurls
//PS:µÚÒ»´ÎÅöµ½Õâ¸öÖ¸Á²»ÖªµÀÄܲ»ÄÜÓÃÀ´°Ñ×Ô¼ºµÄÕ¾µã´ÓËÑË÷ÒýÇæÖÐɾ³ýÄØ£¿
header('HTTP/1.1 301 Moved Permanently');
// ·þÎñÆ÷´íÎó
header('HTTP/1.1 500 Internal Server Error');
// Öض¨Ïòµ½Ò»¸öеÄλÖÃ
header('Location: http://www.example.org/');
// ÑÓ³ÙÒ»¶Îʱ¼äºóÖض¨Ïò
header('Refresh: 10; url=http://www.example.org/');
print 'You will be redirected in 10 seconds';
// Ò²¿ÉÒÔʹÓÃHTMLÓï·¨À´ÊµÏÖÑÓ³Ù
// zip"');
header('Content-Transfer-Encoding: binary');
// ¼ÓÔØÒªÏÂÔصÄÎļþ:
readfile('example.zip');
// ½ûÖ¹»º´æµ±Ç°Îĵµ:&n
Ïà¹ØÎĵµ£º
phpÖÐÈÕÆÚת»»º¯ÊýstrtotimeµÄÓ÷¨:
Óï·¨:
int strtotime ( string time [, int now] )
·µ»Ø½«ÈκÎÓ¢ÎÄÎı¾µÄÈÕÆÚʱ¼äÃèÊö½âÎöΪ Unix ʱ¼ä´Á
ʵÀý:
Ò»£¬»ñÈ¡Ö¸¶¨ÈÕÆÚµÄunixʱ¼ä´Á strtotime("2009-1-22") ʾÀýÈçÏ£º
echo strtotime("2009-1-22") ½á¹û£º1232553600
˵Ã÷£º·µ»Ø2009Äê1ÔÂ22ÈÕ0µã ......
sessionÎļþ±£´æÔÚ·þÎñÆ÷£¬¶Ôÿ¸ösession¶¼»áËæ»úÉú³ÉÒ»¸öΨһµÄsessionIdÀ´½øÐбêʶ£¬Ò»°ãÈç¹ûûÓÐÉèÖÃsessionµÄÉú´æÖÜÆÚ£¬Ôòsession»á±£´æÔÚÄÚ´æÖУ¬¹Ø±Õä¯ÀÀÆ÷£¬¸Ãsessionid»á×Ô¶¯×¢Ïú£¬ÖØÐÂÇëÇóʱÔò×Ô¶¯ÖØзÖÅä¡£
Èç¹û¿Í»§¶ËûÓнûÓÃcookie£¬ÔòÔÚʹÓÃsessionʱ£¬cookie»á°èÑÝ´æ´¢sessionIdºÍsessionÉú´æÖÜÆڵĽÇÉ«¡£¡ ......
<?
$music = $_POST['music'];
//È¡µÃËùÑ¡ÖеÄcheckboxµÄ¸öÊý
$coun=count($music);
if ( is_array( $music ) ) {
echo 'ÄúÑ¡ÔñµÄÊÇ : ';
foreach ( $music as $key => $var )
echo ' ['.$var.']';
......
PHP:
<?php
for
(
$i
=
0
;
$i
<
10
;
$i
++
)
{
echo
$i
;
sleep
(
1
)
;
}
?>
ÀàËÆÉÏÃæµÄ³ÌÐòÈç¹ûÔÚPHP½âÊÍÆ÷ÖÐÖ´ÐУ¬Ã¿Ãë»áÊä³öÒ»¸öÊý£¬ºÍÏëÏóÖÐÒ»Ñù¡£µ«ÊÇÈç¹ûʹÓÃä¯ÀÀÆ÷À´·ÃÎÊ£¬Çé¿ö¾ÍÓÐËù²»Í¬¡£ÔÚä¯ÀÀÆ÷ÖзÃÎÊʱ£¬Ö»ÓÐÔÚÊ®ÃëÖ®ºó²Å»áÒ»´ÎÐÔµØÏÔʾËù ......
Èç¹ûÖ»ÊÇÒ»¸öÊý¾Ý¿âµÄ»°£¬ÎÒÃÇÒ»°ãÏ°¹ßÕâÑùд£ºmysql_select_db("guestbook")£»
mysql_query('select * from users');
µ«ÊÇÈç¹ûÊÇÁ¬½Ó¶à¸ömysql£¬ÓпÉÄܳöÏÖͬÃûµÄÊý¾Ý¿â£¬»òÕßÊý¾Ý¿âÖгöÏÖͬÃûµÄ±í£¬ËùÒԾͱØÐëÓÃÍêÕûµÄÐÎʽÁË£¬ÈçÏ´úÂ룺
<?php
$link1 = mysql_connect('localhost1','root','root');
mysql ......