php代码片段

WBOY
Release: 2016-06-23 14:32:37
Original
2827 people have browsed it

1. PHP网址 URL拼接

$_SERVER['QUERY_STRING']  获取获取当前url的所有querystring

parse_str and http_build_query: 

parse_str($queryString, $params);

foreach ($params as $key => $term)

    $these = array_diff_assoc($params, array($key => $term));

    printf("%s
\n", http_build_query($these), $term);

Example output:

a

b

c
 

参考 http://stackoverflow.com/questions/8609163/php-retrieve-keys-from-query-string-for-each-key-create-url-removing-that-key 

 

2.php 获取当前url

 $url_this =  "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];  

 

3.strtotime("-1 week"), strtotime("-n days");可以很方便的获取当前日期的前n天、周、月的时间戳

 

 

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template