-
- echo date("Y-m-d H:i:s",strtotime("-1 week"))."<br/>";
-
- echo date("Y-m-d H:i:s",strtotime("-1 month"))."<br/>";
-
- print_r(array("hello world"))."<br/>";
-
- echo (print "ddd")."<br/>";
-
- echo strrev("abcdefg")."<br/>";
-
- $str = "abcdefg";
- function strrevv($str){
- $len=strlen($str);
- $newstr = ‘‘;
- for($i=$len-1;$i>=0;$i--){
- $newstr .= $str{$i};
- }
- return $newstr;
- }
- $showstr = strrevv($str);
- echo $showstr."<br>";
-
- $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
- print_r(array_reverse($a));
- Array ( [c] => Horse [b] => Cat [a] => Dog )
-
- echo mb_substr("你好",0,1,"gb2312")."<br/>";
-
- echo $_SERVER[‘REMOTE_ADDR‘];
- echo $_SERVER[‘SERVER_ADDR‘];
- echo $_SERVER[‘PHP_SELF‘];
- echo $_SERVER["HTTP_REFERER"];
- echo gethostbyname("www.v1pin.com");
- echo getenv("REMOTE_ADDR");
- echo getenv("SERVER_ADDR");
-
- $str="abcdefg";
- echo $str{2}."<br/>";
- /**
-
- $content = str_replace($searchs=array("\""), $replaces=array("‘"), $content);
-
- $arr=array(
- "8535455928182811",
- "1558999140182811",
- "1558999140182811",
- "5795844841182811",
- "5795844841182811",
- );
-
- $ordersn_arr=array_unique($arr);
- echo "<pre>";print_r($ordersn_arr);exit;
- function uc_feed_add($icon, $uid, $username, $title_template=‘‘, $title_data=‘‘, $body_template=‘‘, $body_data=‘‘, $body_general=‘‘, $target_ids=‘‘, $images = array()) {
-
-
-
- return call_user_func(UC_API_FUNC, ‘feed‘, ‘add‘,
- array( ‘icon‘=>$icon,
- ‘appid‘=>UC_APPID,
- ‘uid‘=>$uid,
- ‘username‘=>$username,
- ‘title_template‘=>$title_template,
- ‘title_data‘=>$title_data,
- ‘body_template‘=>$body_template,
- ‘body_data‘=>$body_data,
- ‘body_general‘=>$body_general,
- ‘target_ids‘=>$target_ids,
- ‘image_1‘=>$images[0][‘url‘],
- ‘image_1_link‘=>$images[0][‘link‘],
- ‘image_2‘=>$images[1][‘url‘],
- ‘image_2_link‘=>$images[1][‘link‘],
- ‘image_3‘=>$images[2][‘url‘],
- ‘image_3_link‘=>$images[2][‘link‘],
- ‘image_4‘=>$images[3][‘url‘],
- ‘image_4_link‘=>$images[3][‘link‘]
- )
- );
- }
- $arr[] = array("age"=>20,"name"=>"小强");
- $arr[] = array("age"=>21,"name"=>"李伟");
- $arr[] = array("age"=>20,"name"=>"小亮");
- $arr[] = array("age"=>22,"name"=>"黎明");
-
- foreach ($arr as $key=>$value){
- $age[$key] = $value[‘age‘];
- $name[$key] = $value[‘name‘];
- }
-
- array_multisort($age,SORT_NUMERIC,SORT_DESC,$name,SORT_STRING,SORT_ASC,$arr);
- echo "<pre>";print_r($arr);exit;
- $arr1 = array(‘1‘,‘2‘,‘3‘,‘4‘);
- unset($arr1[2]);
- echo "<pre>";print_r($arr1);
-
- $arr2 = array(‘1‘,‘2‘,‘3‘,‘4‘);
- array_splice($arr2, 2, 1);
- echo "<pre>";print_r($arr2);
-
- $arr3 = array(‘1‘,‘2‘,‘3‘,‘4‘);
- array_splice($arr3, 2, 1,array("5"));
- echo "<pre>";print_r($arr3);
-
- $arr4 = array(‘1‘,‘2‘,‘3‘,‘4‘);
- $arr5 = array_slice($arr4, 2, 1);
- echo "<pre>";print_r($arr5);
- function daddslashes($string, $force = 1) {
- if(is_array($string)) {
- $keys = array_keys($string);
- foreach($keys as $key) {
- $val = $string[$key];
- unset($string[$key]);
-
- $string[addslashes($key)] = daddslashes($val, $force);
- }
- } else {
- $string = addslashes($string);
- }
- return $string;
- }
- function fileext($filename) {
-
-
-
- return addslashes(strtolower(substr(strrchr($filename, ‘.‘), 1, 10)));
- }
- function dstrpos($string, $arr, $returnvalue = false) {
- if(empty($string)) return false;
- foreach((array)$arr as $v) {
-
-
- if(strpos($string, $v) !== false) {
- $return = $returnvalue ? $v : true;
- return $return;
- }
- }
- return false;
- }
- function dimplode($array) {
- if(!empty($array)) {
-
-
- $array = array_map(‘addslashes‘, $array);
-
- return "‘".implode("‘,‘", is_array($array) ? $array : array($array))."‘";
- } else {
- return 0;
- }
- }
-
- 再如:
- $brand_id_arr = array_unique(array_map(function ($val) { return $val[‘id‘]; }, $brand_list));
- function dstripslashes($string) {
- if(empty($string)) return $string;
- if(is_array($string)) {
- foreach($string as $key => $val) {
- $string[$key] = dstripslashes($val);
- }
- } else {
- $string = stripslashes($string);
- }
- return $string;
- }
- function aidencode($aid, $type = 0, $tid = 0) {
- global $_G;
-
- $s = !$type ? $aid.‘|‘.substr(md5($aid.md5($_G[‘config‘][‘security‘][‘authkey‘]).TIMESTAMP.$_G[‘uid‘]), 0, 8).‘|‘.TIMESTAMP.‘|‘.$_G[‘uid‘].‘|‘.$tid : $aid.‘|‘.md5($aid.md5($_G[‘config‘][‘security‘][‘authkey‘]).TIMESTAMP).‘|‘.TIMESTAMP;
-
-
-
-
-
- return rawurlencode(base64_encode($s));
- }
- function getattachtablebyaid($aid) {
- $attach = C::t(‘forum_attachment‘)->fetch($aid);
- $tableid = $attach[‘tableid‘];
- return ‘forum_attachment_‘.($tableid >= 0 && $tableid < 10 ? intval($tableid) : ‘unused‘);
- }
-
- function getattachtableid($tid) {
- $tid = (string)$tid;
-
-
-
- return intval($tid{strlen($tid)-1});
- }
-
- function getattachtablebytid($tid) {
- return ‘forum_attachment_‘.getattachtableid($tid);
- }
-
- function getattachtablebypid($pid) {
- $tableid = DB::result_first("SELECT tableid FROM ".DB::table(‘forum_attachment‘)." WHERE pid=‘$pid‘ LIMIT 1");
- return ‘forum_attachment_‘.($tableid >= 0 && $tableid < 10 ? intval($tableid) : ‘unused‘);
- }
-
- function getattachnewaid($uid = 0) {
- global $_G;
- $uid = !$uid ? $_G[‘uid‘] : $uid;
- return C::t(‘forum_attachment‘)->insert(array(‘tid‘ => 0, ‘pid‘ => 0, ‘uid‘ => $uid, ‘tableid‘ => 127), true);
- }
- function tree($dir,$level=1){
-
- $fh=opendir($dir);
-
- while($dirname=readdir($fh)){
- if($dirname == ‘.‘ || $dirname == ‘..‘){
- continue;
- }
-
- echo "|".str_repeat(‘-‘,$level).$dirname;
- echo ‘<br>‘;
- if(is_dir($dir. ‘/‘ .$dirname)){
-
- tree($dir. ‘/‘ .$dirname,$level+2);
- }
- }
- }
-
- tree(‘D:/wamp/www/discuz3/source/‘);
- $a=array(
- 0=>"Dog",
- 1=>"Cat",
- 2=>"Horse"
- );
- echo "<pre>";
- print_r(array_flip($a));
-
- $a=array("Dog","Cat","Horse");
- array_pop($a);
- echo "<pre>";print_r($a);
-
- $a=array("Dog","Cat");
- $b=array("Horse","Bird");
- $num=array_push($a,$b);
- echo "<pre>";print_r($a);
-
- $a=array("a"=>"Dog","b"=>"Cat","c"=>"Horse");
- echo "<pre>";print_r(array_rand($a,2));
-
- $stack = array(
- array("admin","123"),
- array("admin1","123"),
- array("admin2","123"),
- array("admin3","123")
- );
- $fruit = array_shift($stack);
- echo "<pre>";print_r($fruit);
- echo "<pre>";print_r($stack);
-
- $stack = array(
- array("admin1","123"),
- array("admin2","123"),
- array("admin3","123")
- );
-
- $num = array_unshift($stack,array("admin","123"));
- echo "<pre>";print_r($stack);
-
- $stack = array(
- array("admin1","123"),
- array("admin2","123"),
- array("admin3","123")
- );
-
- echo "<pre>";print_r(reset($stack));
- echo "<pre>";print_r(end($stack));
-
- echo crypt("123","v1pin")."<br/>";
-
- echo crypt("admin","v1pin")."<br/>";
-
- echo md5("admin");
- parse_str("id=23&name=John%20Adams");
- echo $id."<br />";
- echo $name."<br/>";
-
- parse_str("id=23&name=John%20Adams",$arr);
- echo "<pre>";print_r($arr);
-
- $url = "http://www.baidu.com/abc/de/fg.php?id=1";
-
- $path = parse_url($url);
- echo "<pre>";print_r($path);
-
-
- echo "<pre>"; print_r(pathinfo($path[‘path‘]));
- echo pathinfo($path[‘path‘],PATHINFO_DIRNAME)."<br/>";
- echo pathinfo($path[‘path‘],PATHINFO_BASENAME)."<br/>";
- echo pathinfo($path[‘path‘],PATHINFO_EXTENSION)."<br/>";
- echo dirname($path[‘path‘])."<br/>";
- echo basename($path[‘path‘])."<br/>";
- $url = "http://www.baidu.com/abc/de/fg.php?id=1";
- echo basename($url)."<br/>";
- echo strripos(basename($url),"?")."<br/>";
- echo substr(basename($url),0,strripos(basename($url),"?"))."<br/>";
-
-
-
-
- echo number_format("1234567890")."<br/>";
- echo number_format("1234567890",2)."<br/>";
- echo number_format("1234567890",2,",",".")."<br/>";
-
- $url = "http://www.baidu.com/abc/de/fg.php?id=1";
- echo basename($url)."<br/>";
- echo strripos(basename($url),"?")."<br/>";
- echo substr(basename($url),0,strripos(basename($url),"?"))."<br/>";
- echo substr("fg.php?id=1",0,6);
-
- function str_change($str) {
- $str = str_replace ( "_", " ", $str );
- $str = ucwords ($str);
- $str = str_replace(" ","",$str);
- return $str;
- }
-
- echo str_change("open_door")."<br/>";
- echo str_change("make_by_id")."<br/>";
-
- function str_change1($str) {
- $str_arr = explode("_", $str );
- foreach($str_arr as $key => $val){
- $str_arr[$key] = ucwords ($val);
- }
- return implode("",$str_arr);
- }
-
- echo str_change1("open_door")."<br/>";
- echo str_change1("make_by_id")."<br/>";
- echo $str1=implode("",array_map(function($val){return ucwords($val);},explode("_","open_door")));
- echo $str2=implode("",array_map(function($val){return ucwords($val);},explode("_","make_by_id")));
- echo $str3=implode("",array_map(‘ucwords‘,explode("_","open_door")));
- echo $str4=implode("",array_map(‘ucwords‘,explode("_","make_by_id")));
- $arr1=explode("_","open_door");$flag=@array_walk($arr1,‘ucwords‘);echo implode("",$arr1);
- $arr2=explode("_","make_by_id");$flag=@array_walk($arr2,‘ucwords‘);echo implode("",$arr2);
-
- echo (strtotime("2007-3-6")-strtotime("2007-2-5"))/(3600*24);
-
- echo $_SERVER[‘REQUEST_URI‘];
-
- $array = array(‘AAA‘, ‘bbb‘);
- $map_array = array_map(‘strtolower‘, $array);
- print_r($map_array);
- print_r($array);
-
-
- function array_walk_func(&$v, $k){
- $v = strtolower($v);
- }
- $walk_array = array_walk($array, ‘array_walk_func‘);
- print_r($walk_array);
- print_r($array);
- class Deque{
- public $queue;
- public function __construct(){
- $this->queue = array();
- }
-
- public function addFirst($item){
- return array_unshift($this->queue , $item);
- }
-
- public function removeFirst(){
- return array_shift($this->queue);
- }
-
- public function addLast($item){
- return array_push($this->queue , $item);
- }
-
- public function removeLast(){
- return array_pop($this->queue);
- }
- }
目录:
1、php如何打印出上周的时间格式?如:"2015-01-22 14:42:09"
2、php如何打印出上周的时间格式?如:"2015-01-15 14:42:09"
3、php如何打印出上个月的时间格式?如:"2014-12-22 14:42:09"
4、简述一下echo、print、print_r 区别?
5、php如何实现字符串反转?如:"abcdefg" 反转成 "gfedcba"
6、php如何实现中文字符串截取无乱码的方法(mb_*系列函数)
7、php如何写出显示客户端和服务器端IP的代码
8、mysql中 IFNULL 控制流函数;IFNULL()
9、简述include与require的区别?
10、php如何获取一个字符串中指定的字符?
11、php如何批量替换字符串中的特定字符?如:"批量替换$content内容字符串中的所有双引号为单引号"
12、php如何将UEditor或FCkeditor编辑器中的内容转化为JSON串?
13、php中addslashes()与 htmlspecialchars()区别
14、php如何去除数组中重复的值?使用数组函数 array_unique() 可以做到
15、php中$GLOBALS全局变量和global关键字的区别?
16、php中回调函数 call_user_func() 如何使用?
17、php中如何使用 array_multisort() 函数实现对多维数组进行排序?
18、php中移除数组元素有几种方式?
19、php中如何对数组元素进行递归转义?
20、php中如何获取文件扩展名?
21、php中如何查找一个字符串是否在数组元素中出现过,如何出现过,则返回该数组元素?
22、php中常用的回调函数有哪些?
23、php中递归反转义
24、php中常用的编码函数汇总
25、discuz中附件表的分表规则
26、php中如何递归循环某目录下的子目录及文件并输出
27、php中如何交换数组中的键和值?
28、php中如何删除数组中最后一个元素?
29、php中如何向数组的尾部添加一个或多个元素?
30、php中如何从数组中随机选出一个或多个元素,并返回
31、php中如何将数组中的第一个元素移出?
32、php中如何在数组开头添加一个或多个元素?
33、php中排序函数汇总
34、php中reset()及end()函数的使用
35、php中crypt()及md5()单向加密函数的使用
36、php中parse_str()函数把查询字符串解析到变量中
37、写一个函数,尽可能高效的,从一个标准 url 里取出文件的扩展名,例如:/abc/de/fg.php?id=1 需要取出 php 或 .php
38、在HTTP 1.0中,状态码 401 的含义是();如果返回“找不到文件”的提示,则可用 header 函数,其语句为()
39、开启php.ini文件中的safe_mode选项,会影响到哪些函数的应用?至少说出四个
40、简述POST和GET传输的最大容量是多少?
41、如何通过form表单控制上传文件的大小?
42、用最简单的代码编写一个获取三个数字中最大值的函数?
43、如何将 1234567890 转换成 1,234,567,890 每三位用逗号隔开的形式?
44、如何尽可能高效的从标准URL中取得文件名?
45、php中stripos()、strpos()、strripos()、strrpos() 字符串函数的区别?
46、请写一个函数,实现以下功能:字符串"open_door" 转换成 "OpenDoor"、"make_by_id" 转换成 "MakeById"
47、php中如何求两个日期的差数,例如2007-2-5 ~ 2007-3-6 的日期差数
48、如何用php的环境变量得到一个网页地址的内容?
49、php中回调函数array_map()和array_walk()的区别?
50、如何使用php实现双向队列?