獲取時間戳
時間戳是指自1970 01 01 00:00:00到現在這一瞬間的秒數。
// microtime(true)常用於測試程式執行時間
$start
=microtime
(true);
for($i=
1;$i<
1000;$i
++)$end
=microtime
(true);
echo
$end
-$start
;
時間戳格式化
$time
=time()
;echo
date
("y-m-d 星期n h:i:s"
,$time);
// 2019-10-21 星期1 03:27:22
echo""
;echo
gmdate
("y-m-d 星期n h:i:s");
// 2019-10-21 星期1 03:27:22
獲取某個日期的時間戳
echo
mktime(12
,10,10
,10,21
,2019);
echo""
;echo
strtotime
("now");
// 此時的時間戳
echo""
;echo
strtotime
("now +1 day");
// 明天的時間戳
echo""
;echo
strtotime
("now -1 day");
// 昨天的時間戳
檢測日期是否合法
// 檢測日期是否合法
var_dump
(checkdate(2
,29,2000))
;// boolean true
var_dump
(checkdate(2
,29,2019))
;// boolean false
var_dump
(checkdate(6
,31,2019))
;// boolean false
str_repeat() 函式
// 用遞迴列印當前目錄所有檔案 用str_repeat() 實現分級
<?php
function
fun(
$path
,$lev=1
)if(is_dir
($path
.'/'
.$file))
}}$path
='.'
;fun
($path
);
directory 函式允許您獲得關於目錄及其內容的資訊。
<?php
$dir
="/images/"
;// open a directory, and read its contentsif(
is_dir
($dir))
closedir
($dh);
}}?>
// 未完成 有的地方不太懂
<?php
$path
="../"
;print_r
($_server
['request_uri'])
;$url
=$_server
['request_uri'];
//print_r($path);if(
isset
($_get
['dir'])
)$item
=array()
;if(is_dir
($path))
closedir
($th);
}}?>
<
!doctype html>
"en"
>
"utf-8"
>
"viewport"
content=
"width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"
>
"x-ua-compatible" content=
"ie=edge"
>
檔案管理系統<
/title>
td <
/style>
<
/head>
序號<
/td>
檔名<
/td>
操作<
/td>
<
/tr>
<?php
foreach
($item
as$key
=>
$value
)else
echo'';
echo'';
};?>
<
/table>
<
/body>
<
/html>
PHP內建函式複習
arr a b c d print array shift arr 輸出 a str 1.php?d.com print strrchr str,return com 返回字串長度 strlen 把字串打散為陣列 str hello world lilili arr explode str 返回乙個...
PHP引數內建函式
addslashes mysql real escape string mysql escape string 都是給字串新增 過濾 單引號 雙引號 反斜線 空字元null.其中mysql escape string addslashes 可能存在寬位元組繞過問題。htmlspecialchars ...
php多少內建函式,php有多少個內建函式
1 filter var函式 2 prase url函式 解析url返回各個組成部分 url print r parse url url echo parse url url,php url path 以上結果會輸出 array scheme https host www.baidu.com pat...