<?php
$cookie_name = "user";
$cookie_value = "John";
setrawcookie($cookie_name, $cookie_value, time() + (86400 * 30), "/");
// 86400 = 1 day
?>
<html>
<body>
stockwfj3 發表在 痞客邦 留言(0) 人氣(7)
<?php
// 打開syslog,包括進程ID並發送日誌到標準錯誤,並使用用戶定義記錄機制
openlog("myScriptLog", LOG_PID | LOG_PERROR, LOG_LOCAL0);
stockwfj3 發表在 痞客邦 留言(0) 人氣(77)
<?php
$ip_long = 2635544666;
echo long2ip($ip_long);
stockwfj3 發表在 痞客邦 留言(0) 人氣(13)
<?php
$ip = gethostbyname('www.example.com');
$out = "The following URLs are equivalent:<br />\n";
$out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/<br />\n";
echo $out;
?>
stockwfj3 發表在 痞客邦 留言(0) 人氣(8)
<?php
$ip = gethostbyname('www.example.com');
$out = "The following URLs are equivalent:<br />\n";
$out .= 'http://www.example.com/, http://' . $ip . '/, and http://' . sprintf("%u", ip2long($ip)) . "/<br />\n";
echo $out;
?>
stockwfj3 發表在 痞客邦 留言(0) 人氣(110)
<?php
$packed = chr(127) . chr(0) . chr(0) . chr(1);
$expanded = inet_ntop($packed);
stockwfj3 發表在 痞客邦 留言(0) 人氣(48)
<?php
// Get the current response code and set a new one
var_dump(http_response_code(404));
stockwfj3 發表在 痞客邦 留言(0) 人氣(557)
<?php
// 如果沒有發送頭,請發送一個
if (!headers_sent()) {
header('Location: http://www.example.com/');
exit;
}
stockwfj3 發表在 痞客邦 留言(0) 人氣(57)
<?php
/* setcookie() will add a response header on its own */
setcookie('foo', 'bar');
stockwfj3 發表在 痞客邦 留言(0) 人氣(9)
例1 取消設置特定的頭部。
<?php
// 我們將輸出一個PDF
header('Content-Type: application/pdf');
stockwfj3 發表在 痞客邦 留言(0) 人氣(75)