
PHP
scchary
这个作者很懒,什么都没留下…
展开
-
PHP的反射类ReflectionClass、ReflectionMethod学习记录
在看thinkphp代码发现这个两个类,网上搜了下,说是实现原创 2014-11-05 11:50:27 · 2801 阅读 · 0 评论 -
页面最大过期时间
1. [代码]php.ini 123//在php.ini 中设置,如30秒 max_execution_time = 302. [代码]ini_set()函数 123//虚拟主机,且服务器允许使用ini_set()函数,可在PHP代转载 2014-12-30 14:55:01 · 647 阅读 · 0 评论 -
php返回json格式数据
$arr=array('tyc_id'=>$tyc_id, 'tyc_name'=>$_POST['tyc_name'], 'sta'=>'ok' );//虽然这行数据形式上是json格式的字符串数据,发送给前台的js处理的时候还要用eval函数转换一下才能当成json数据使用,不然只是一个json格式的字符串;ech原创 2014-10-13 15:10:44 · 4241 阅读 · 0 评论 -
php打开报错
ini_set("display_errors",1); error_reporting(E_ALL);转载 2015-03-24 09:42:11 · 543 阅读 · 0 评论 -
计算字符串的不同,优化之后
//检测字符串相同的部分function check_str($str1,$str2){ static $str_length_flag=1000000000; static $flag=0; $tmp_str1=$str1;$tmp_str2=$str2; $strlen=utf8_strlen($str1); $str_temp=''; for (原创 2015-04-28 16:28:23 · 395 阅读 · 0 评论 -
计算两个字符串的不同
<?phpheader('Content-type:text/html;charset=utf-8;');$str1='哈哈哈213213sdfsdf';$str2='test哈哈';echo $str1;echo "";echo $str2;echo "";//echo mb_substr($str1, 5, utf8_strlen($str1)-5, 'utf-8');die(原创 2014-12-09 11:24:02 · 499 阅读 · 0 评论 -
php面试常见算法
一、常见字符串和文件操作1、PHP翻转中文字符串function reverse($str){ $r = array(); for($i=0; $i<mb_strlen($str); $i++){ $r[] = mb_substr($str, $i, 1, 'UTF-8'); } return implode(array_reverse($r));}转载 2015-05-06 09:55:20 · 498 阅读 · 0 评论 -
php运行模式
PHP运行模式有4钟: 1)cgi 通用网关接口(Common Gateway Interface)) 2) fast-cgi 常驻 (long-live) 型的 CGI 3) cli 命令行运行 (Command Line Interface) 4)web模块模式 (apache等web服务器运行的模块模式)CGI(Common Gateway Interface) CGI即通用网转载 2015-05-06 10:02:07 · 427 阅读 · 0 评论 -
抓取百度搜索结果
抓取百度搜索结果,但是用file_get_content会出现false 后来找到一个函数function curlPost($url, $data=array(), $timeout = 30){ // $interface = "eth0:" . rand(1, 4); //避免GG封IP // curl_setopt($ch, CURLOPT_FOLLOWLOCATION,原创 2015-06-15 12:36:39 · 820 阅读 · 0 评论 -
php访问局域网内机器的文件
今天有个需求,需要访问局域网内机器的文件,之前没做过,折腾了一天,$location = "\\\\192.168.1.111\\d$";//184机器上面的d盘//$location = "\\\\192.168.1.184\\d$\\baidu_syn";//184机器上面的d盘的baidu_syn文件夹$user = "administrator";//用户名$pass = "xxxx"原创 2015-07-16 16:46:18 · 3274 阅读 · 2 评论 -
输出当前包含过的文件
get_included_files() 学习了,转载自http://www.dewen.io/q/4369转载 2015-07-22 14:18:51 · 404 阅读 · 0 评论 -
7个鲜为人知却非常实用的PHP函数
概述PHP有着众多的内置函数,其中大多数函数都被开发者广发使用。但也有一些同样有用却被遗忘在角落,本文将介绍7个鲜为人知功能却非常酷的函数。1.highlight_string()当需要在网页中展示PHP代码时,highlight_string()函数就显得非常有用。该函数通过PHP内置定义的颜色,返回函数中代码的高亮显示版本。<?php highlight_string('<?php e转载 2015-07-22 16:25:36 · 572 阅读 · 0 评论 -
修改php.ini配置文件无效
写了个程序,会出现一个警告错误 因为涉及到了时间的几个函数,会报告警告错误...It is not safe to rely on the system’s timezone settings...是因为没有设置时区导致的,于是去修改php.ini里面的默认时区,但是发现修改无效,时区还是未设置的状态,重启服务的时候也不报错 于是使用了下面的命令 1023 history [root@www原创 2015-09-12 10:08:43 · 4347 阅读 · 0 评论 -
php取得json前面有乱码
需要在两个服务器之间通信,但返回结果为json{"time":1442049120,"content":"\u54c8\u54c8\u54c8\u54c8\u54c8\u54c8\u54c8","validTime":10}直接访问服务器端服务器看是ok的 但是在客户端服务器var_dump返回值发现成了string '锘縶"time":1442049350,"content":"\u54c8\u原创 2015-09-12 17:21:33 · 3254 阅读 · 0 评论 -
获取文件时间
ilemtime ( string filename )返回文件上次被修改的时间,出错时返回 FALSE。时间以 Unix 时间戳的方式返回,可用于 date()。例如:$a=filemtime("log.txt"); echo "修改时间:".date("Y-m-d H:i:s",$a)."filectime ( string filename )返回文件转载 2014-12-29 08:55:51 · 568 阅读 · 0 评论 -
复习pdo,插入,查询
好久之前了解过pdo,最近一直在用tp做开发,东西都忘记了。。。。。正好今天做一个单一的功能,复习下pdo~~~<?php/*** 写一个pdo类*/class mypdo{//放连接对象public $connect='';//放执行语句public $sql='';//放变量function __construct($host,$dbname,$username,$pw原创 2014-12-24 17:18:39 · 479 阅读 · 0 评论 -
循环创建文件夹
function mk_dir($path){ $path=str_replace('./', '/', $path); $path=substr($path,0,strrpos($path,'/')); $path_arr=explode('/', $path); unset($path_arr[0]); $path=''; foreach ($p原创 2014-12-09 11:39:45 · 1514 阅读 · 0 评论 -
php一些用到的路径的一些函数~~
var_dump(__FILE__);//var_dump(realpath('./'));原创 2014-11-04 10:23:48 · 415 阅读 · 0 评论 -
PHP中刷新输出缓冲
转载自:http://www.cnblogs.com/mutuan/archive/2012/03/18/2404957.html转载 2014-11-07 14:58:53 · 399 阅读 · 0 评论 -
ob_start相关函数学习
在看thinkphp源码的时候原创 2014-11-06 16:56:48 · 576 阅读 · 0 评论 -
PHP 5.3.1 安装包 VC9 VC6 区别是什么
在PHP100混了这么久也写点东西出来吧,最近在PHP官网上看到又有新版的PHP下载了,于是上去找找For Windows的版本,可是一看确傻眼了,一共给了四个版本,VC9 x86 Non Thread Safe、VC9 x86 Thread Safe、VC6 x86 Non Thread Safe、VC6 x86 Thread Safe,这让我这个菜鸟头疼啊,还好PHP官网提供下载的地方左边有个转载 2014-11-19 10:57:43 · 620 阅读 · 0 评论 -
widows下面安装xdebug
今天[XDebug]xdebug.profiler_append = 0xdebug.profiler_enable = 1xdebug.profiler_enable_trigger = 0xdebug.profiler_output_dir ="D:\WEBserver\tmp\xdebug"xdebug.trace_output_dir ="D:\WEBs转载 2014-11-19 11:32:44 · 395 阅读 · 0 评论 -
curl下载函数
//curl文件下载function curl_download($url,$filename,$suffix='jpg'){ $timeout=5; $curl=curl_init();//初始化一个cURL会话 curl_setopt($curl, CURLOPT_URL, $url);//文件地址设置 curl_setopt($curl,CURLOPT_R原创 2014-11-27 16:56:38 · 694 阅读 · 0 评论 -
php数组函数(用到的就记录下)
$test_arr=array('aaa'=>1,'bbb'=>2);$callback=function ($value,$key){ echo $key."=>".$value;};array_walk($test_arr,$callback);//原创 2014-11-03 16:07:37 · 401 阅读 · 0 评论 -
static变量的一些疑惑
<?phpfunction test($name){ static $_trace = array(); $_trace[]=$name; var_dump($_trace);}for ($i=0; $i <5 ; $i++) { test($i);}?>原创 2014-10-30 15:15:16 · 433 阅读 · 0 评论 -
$_POST,php://input,$_GET直接的区别
代码参考1, php://input 可以读取http entity body中指定长度的值,由Content-Length指定长度,不管是POST方式或者GET方法提交过来的数据。但是,一般GET方法提交数据 时,http request entity body部分都为空。2,php://input 与$HTTP_RAW_POST_DATA读取的数据是一样的,都只读取Co原创 2014-11-06 10:30:02 · 2806 阅读 · 0 评论 -
php发送get,post请求学习
学习http://blog.youkuaiyun.com/haha00217/article/details/7969504原创 2014-11-05 14:29:23 · 855 阅读 · 0 评论 -
php闭包学习~~
<?php//提到闭包就不得不想起匿名函数,//也叫闭包函数(closures),貌似PHP闭包实现主要就是靠它。声明一个匿名函数是这样:$func=function ($value=''){ echo "test!!!";};$func();//输出test!!!?>原创 2014-11-03 10:08:58 · 470 阅读 · 0 评论 -
php操作html元素,使用PHP Simple HTML DOM Parser
今天需要一个操作html元素的的功能,记得php有xml的,但是用的真心少,在网上搜下教程,没想到还有PHP Simple HTML DOM Parser这个开源项目,看了下介绍,可以像jquery那样操作html,赶紧下载下来体验下代码如下<?phpheader('Content-type:text/html;charset=gb2312;');//首先引入类文件require原创 2014-12-24 12:32:17 · 3120 阅读 · 0 评论 -
关于magic_quotes_sybase
转载自:http://blog.163.com/wangzhenbo85@126/blog/static/101363282201192242358226/当php.ini设置magic_quotes_sybase为on时会覆盖magic_quotes_gpc为on的处理,然而magic_quotes_sybase仅仅是转义了nullbyte和把'变成了'' set_magic_quo转载 2014-12-09 16:08:59 · 1671 阅读 · 0 评论 -
php异步http请求
//因为是用fsockopen实现的所以需要自己写http请求function getPostHeader($url,$data){// $URL='http://test.com/001/test.php'; $URL = $url; $data_string = http_build_query($data); $referrer="";// parsing原创 2015-10-19 12:01:51 · 1697 阅读 · 0 评论