format('Y-m-d H:i:s'); 返回到上一页: //"/> format('Y-m-d H:i:s'); 返回到上一页: //">

Home  >  Article  >  Backend Development  >  4个php技巧小结

4个php技巧小结

WBOY
WBOYOriginal
2016-06-20 13:00:48971browse

 

获得服务器时间:

date_default_timezone_set('PRC'); //其中PRC为"中华人民共和国"
$serverDate = date("Y-m-d G:i:s");

日期格式化:

$date = new DateTime('2000-01-01');
echo $date->format('Y-m-d H:i:s');

返回到上一页:

//php方式
header("Location: " . $_SERVER['HTTP_REFERER']);
 
//js方式
echo "<script>history.back();</script>";
echo '<script>window.location="...url";</script>'; //跳转到指定页面
echo '<script>self.location.reload();</script>'; //刷新当前页面

@符号

不显示错误信息(加在函数前)


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn