![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LANGUAGE_php
文章平均质量分 78
陈善
这个作者很懒,什么都没留下…
展开
-
session_set_save_handler 举例 (将session值存入mysql)
<?php$id = $_GET["id"];if (session_id() == $id) { @session_destroy();}session_set_save_handler("sess_open", "sess_close", "sess_read", "sess_write", "sess_destroy", "sess_gc");session_id($id)原创 2012-03-19 14:02:41 · 558 阅读 · 0 评论 -
php判断http头还是https头
1.一个语句:$http_type = ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') || (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')) ? 'https://' : 'http://'原创 2012-07-05 11:14:58 · 6892 阅读 · 0 评论 -
php download 语句
1.Basicheader("Content-type: text/directory");header("Content-Disposition: attachment; filename=" . "ok" . ".text" . "");header("Pragma: public");print "haha i am yes. ok!";$file = "/tmp/dumm原创 2012-04-16 10:00:51 · 437 阅读 · 0 评论 -
第一次在html中使用js
1.代码如下: 设置新密码 function _url(){ var Url=top.window.location.href; var u,g,StrBack=''; if(arguments[argument原创 2012-07-09 17:14:23 · 493 阅读 · 0 评论 -
初识 curl (安装与示例)
1.安装php的curl扩展命令:sudo apt-get install curl libcurl3 libcurl3-dev php5-curl2.示例<?php// Create a curl handle$ch = curl_init('http://www.hao123.com/');// Execute$result = curl_exec($ch);原创 2012-06-27 14:36:01 · 515 阅读 · 0 评论 -
基于PHP的cURL快速入门
cURL 是一个利用URL语法规定来传输文件和数据的工具,支持很多协议,如HTTP、FTP、TELNET等。最爽的是,PHP也支持 cURL 库。本文将介绍 cURL 的一些高级特性,以及在PHP中如何运用它。为什么要用 cURL?是的,我们可以通过其他办法获取网页内容。大多数时候,我因为想偷懒,都直接用简单的PHP函数:$content = file_get_contents("转载 2012-06-27 15:01:15 · 467 阅读 · 0 评论 -
PHP 正则表达式资料
每个PHP程序员都知道PHP有强大的正则表达式功能,为了以后的工作方便,我从网上整理了关于正则表达式的资料,方便以后工作时的进行资料查阅。 正则表达式(regular expression)描述了一种字符串匹配的模式,可以用来检查一个串是否含有某种子串、将匹配的子串做替换或者从某个串中取出符合某个条件的子串等。 举例来说,正则表达式的一个最为普遍的应用就是用于验证用转载 2012-06-27 15:55:38 · 437 阅读 · 0 评论 -
php扩展 oauth 安装(sudo apt-get)
1.命令:sudo apt-get install php5-dev php-pear libpcre3-devsudo pecl install oauth2.修改配置文件:extension=oauth.so原创 2012-06-28 22:09:53 · 1458 阅读 · 1 评论 -
php安装http扩展(sudo apt-get install)
转自:http://www.xwuxin.com/?p=1575点击打开链接"上面新需求准备采用kohana,kohana是很早之前从ci分出来的一个框架,轻量,没有像ci那样去兼容php4。kohana需要安装http扩展,在Ubuntu上折腾了下,遇到些问题记录在此:在安装好pecl的前提下:sudo apt-get install libcurl3-openssl-d转载 2012-03-28 22:02:24 · 1708 阅读 · 0 评论 -
安装smarty
1.安装源文件1.1sudo apt-get install smarty1.2sudo vim /etc/php5/apache2/php.ini修改一行: include_path = ".:/usr/share/php:/usr/share/pear:/usr/share/php/smarty/libs"1.3sudo /etc/init.原创 2012-08-06 15:53:22 · 536 阅读 · 0 评论 -
How To Create Your Own Smarty Function
How To Create Your Own Smarty FunctionSmarty makes it really easy to add a function. All you need to do is follow these 3 easy steps.Step 1: Name Your Plugin and Add a HeaderTo start, you’ll nee转载 2012-08-07 14:08:26 · 494 阅读 · 0 评论 -
如何安装redis 如何安装phpredis
一.Redis installation in LinuxInstallation:yum install gitgit clone git://github.com/antirez/rediscd redis./redis-server./redis-cliFiles:redis-benchmarkredis-cliredis-serverredi转载 2012-07-24 22:17:11 · 523 阅读 · 0 评论 -
PHP删除数组元素的具体函数介绍: count 与 array_splice
我们在使用PHP语言进行实际代码编写时,经常会和数组打上交道,这对于初学者来说是比较困难的。今天我们就要向大家介绍如何实现PHP删除数组元素。PHP中的数组要添加元素非常简单,直接用赋值就行了,数组的key会自动增加,但是要删除数组中的元素呢?你想过吗?是不是很少遇到?我近日在处理一个购物篮程序时遇到了要实现PHP删除数组元素的问题,寻找了半天,终于找到了删除数组的方法,其实很简单.开转载 2012-08-10 19:50:24 · 692 阅读 · 0 评论 -
php判断比较两个数组中的数据(得出删除的,和新增的)
<?php$q = array('b','c','d','e'); $s = array('b','c','e','f','g'); //共同的部分$m=array_intersect($q,$s); print_r($m);//老的数据$old=array_diff($q,$m);print_r($old);//新的数据$new=array_diff($s,$m);p转载 2012-08-11 14:33:09 · 1325 阅读 · 0 评论 -
php历史
PHP(PHP:Hypertext Preprocessor)是一种在电脑上执行的脚本语言,主要是用途在于处理动态网页,也包含了命令列执行接口(command line interface),或者产生图形使用者接口(GUI)程式。PHP 最早由 Rasmus Lerdorf 在1995年发明,现在PHP实质上的标准由PHP Group和开放源代码社群维护。PHP 以 PHP License 作转载 2012-08-23 10:54:30 · 538 阅读 · 0 评论 -
PHP 调用shell命令
可以使用的命令:popenfpassthrushell_execexecsystem1.popenresource popen ( string command, string mode )打开一个指向进程的管道,该进程由派生给定的 command 命令执行而产生。 返回一个和 fopen() 所返回的相同的文件指针,只不过它是单向的(只能用于读或写)并且必转载 2012-08-28 10:48:21 · 980 阅读 · 0 评论 -
如何将数组转换为多个参数赋值给另一个函数或方法
1。使用 eval 函数2。使用 call_user_func_array 函数参考:http://bbs.phpchina.com/thread-66402-1-1.html点击打开链接原创 2012-09-13 16:59:30 · 2193 阅读 · 0 评论 -
A Function to Do All My SQL Statements Based On All The Others Comments
Hi, I just write a function to do all my sql statements based on all the others comments in this page, maybe it can be useful for someone else :)Usage:execSQL($sql, $parameters, $close);$s转载 2012-09-13 16:56:42 · 1110 阅读 · 0 评论 -
php发送get、post请求的几种方法 以及获取内容
方法1: 用file_get_contents 以get方式获取内容$url='http://www.domain.com/';$html = file_get_contents($url);echo $html;?>方法2: 用fopen打开url, 以get方式获取内容$fp = fopen($url, 'r');stream_get_meta_data($转载 2012-06-20 16:50:06 · 1076 阅读 · 0 评论 -
PHP实现最简单爬虫原型
<?php/** * 爬虫程序 -- 原型 * * BookMoth 2009-02-21 *//** * 从给定的url获取html内容 * * @param string $url * @return string */function _getUrlContent($url) { $handle = fopen($url, "r"); if ($ha转载 2012-06-19 14:45:06 · 566 阅读 · 0 评论 -
数组处理
1.each,list,reset$fruit = array('a' => 'apple', 'b' => 'banana', 'c' => 'cranberry');reset($fruit);while (list($key, $val) = $a = each($fruit)) { print_r($a); echo "\n$key => $val\n";原创 2012-04-12 16:33:18 · 409 阅读 · 0 评论 -
字符串处理
1.字符串分割函数(处理vcard格式)$line = "a:b;N:Smith;Jim;Al:v:in;:M:r.";$line = rtrim($line);$tmp = split_quoted_string(":", $line,3);print_r($tmp);function split_quoted_string($d, $s, $n = 0){ $quo原创 2012-04-12 17:40:24 · 388 阅读 · 0 评论 -
看懂 php源码的步骤心得
1.先搞懂每个文件;文件里的每个模块,每个类是干嘛的.2.找到程序的入口与出口.3.一步步分析从入口到出口方法:在程序中加入 打印语句 写入文件语句 及 下载文件语句 等进行输出,达到分析程序流程的目的.打印语句:echo print_r 等.写入文件语句: $fp = fopen('output.txt', 'a+');原创 2012-04-16 18:43:38 · 1766 阅读 · 0 评论 -
php http扩展 构造请求 第一次实例
1. define("URL", "http://localhost/*.php"); $send = array('example_post' => "hello world"); $url = URL; $_request = new HttpRequest($url, HTTP_METH_POST); $_request->setPostFi原创 2012-04-16 18:49:30 · 492 阅读 · 0 评论 -
什么是CGI、FastCGI、PHP-CGI、PHP-FPM、Spawn-FCGI?
"什么是CGI CGI全称是“公共网关接口”(Common Gateway Interface),HTTP服务器与你的或其它机器上的程序进行“交谈”的一种工具,其程序须运行在网络服务器上。 CGI可以用任何一种语言编写,只要这种语言具有标准输入、输出和环境变量。如php,perl,tcl等 什么是FastCGI FastCGI像是一个常驻(long-live)型的C转载 2012-04-20 09:00:06 · 345 阅读 · 0 评论 -
省略PHP结束标记 “?>”的好处
(一) php有四种风格的标记: 1、简短风格 //短标签,需在php.ini中配置 short_open_tag=on 2、脚本风格 3、标准风格 4、ASP风格 //也需要在php.ini中配置 asp_tags=on (二)在Zend Framework 与 CodeIginter框架中,都没转载 2012-04-22 12:52:00 · 2672 阅读 · 0 评论 -
PHP详解ASCII码对照表与字符转换 && 字符串处理函数库
"(转自:http://home.phpchina.com/blog-83109-193258.html)PHP基础篇详解ASCII码对照表与字符转换,讨论ASCII码对照表图与字符转换为十进制、八进制、十六进制和HTML的方法一,通用的ASCII码对照表图解ASCII码对照表图,以字符A为例Dec表示十进制,如65Hx表示十六进制,如4转载 2012-04-22 13:01:18 · 934 阅读 · 0 评论 -
php安装http扩展 (源码包)
php的HTTP扩展添加方法:参考资料: http://cn.php.net/manual/en/install.pecl.phpize.phphttp://www.mkfoster.com/2009/01/04/how-to-use-the-pecl-http-pecl_http-extension-to-make-http-requests-from-php/原创 2012-04-22 12:46:05 · 1594 阅读 · 0 评论 -
php http扩展;json串的一个作用;oauth的signature函数 (09-01-1012)
今天解决的小问题挺多的:1.php http扩展:学会如何使用php中http的扩展来自定义http请求:关键是学会了The HttpRequest这个类的运用(运行send成员函数就发送了请求,然后返回一个http响应对象)2.json串的一个作用:之前在做黄页搜索的时候,返回客户端的都是用json_encode()把返回客户端的值转为json串的形式,现在明白了,因为http响应体原创 2012-04-22 12:50:14 · 534 阅读 · 0 评论 -
如何学习Linux 下 c 语言对 php 的扩展 (从零到上手)
如何学习Linux下c语言对php的扩展(从零到上手)1.上篇:从只懂c基本语法且php为零基础,到编译出helloword,到知道php扩展模块构建的基本流程(注:上篇中的命令如果执行不出结果,则需要加“sudo”,以root用户执行命令。)1.1搭建php环境(我的系统先装了mysql)1.1.1.下载php二进制文件:sudoapt-get install原创 2012-04-22 12:57:33 · 966 阅读 · 0 评论 -
php实现 DES/CBC/PCCS5padding 加解密模式
<?php/* 名称:DES/CBC/PCCS5padding 模式加解密测试模块 功能:测试 使用 DES/CBC/PCCS5padding 模式进行加解密的模块 作者: 更新时间: *///Quick Test$h_user_password = “”;$token_secret = "";$token_key_with_oauth_nonce = “”;转载 2012-05-14 08:25:32 · 6487 阅读 · 0 评论 -
Advanced PHP Programming -- 以键值对的形式取得命令行参数 (Console/Getopt.php 的使应用 P130)
function getOptions($default_opt, $shortoptions, $longoptions) { require_once ("/usr/share/php/Console/Getopt.php"); $con = new Console_Getopt; $args = Console_Getopt::readPHPArgv(); $原创 2012-06-11 17:05:19 · 637 阅读 · 0 评论 -
ubuntu编译安装PHP5.4.0+Nginx(FPM/FastCGI)
PHP5.4.0发布了,添加了很多新特性,于是今天在ubuntu下编译安装了PHP5.4+Nginx1.0.13+Memcache,让PHP以fastcgi模式运行。MySQL就不装了用以前的5.1版本的。附张图:安装编译过程遇到许多小问题,折腾了一个晚上,现在整理下:(1):卸载以前通过源安装的php5.3.2和apachesudo apt-get –purge remove转载 2012-05-23 22:32:21 · 1098 阅读 · 0 评论 -
安装 phpdaemon (ubuntu12.04)
主要参考官网安装文档:https://github.com/kakserpom/phpdaemon/wiki/Installation-%28common%29点击打开链接1.下载源码:https://github.com/kakserpom/phpdaemon/archives/master点击打开链接文件放到预安装目录,然后解压:tar xzf phpdaemon*.tar原创 2012-05-24 09:46:09 · 853 阅读 · 0 评论 -
Howto: Enable PCNTL in Ubuntu PHP installations
PCNTL in PHP allows for some handy advanced “trickery” using the OS process functions inherent in Linux (*nix?). I believe some features are available in Windows, but I know for certain thatpcntl_f转载 2012-05-23 22:51:19 · 954 阅读 · 0 评论 -
exec() file_get_contents() file_put_contents() 示例
1.<?php$abc = "chenshan";exec("ls", $out);$tmp_out = json_encode($out);exec("echo $tmp_out > tmp2.txt");file_put_contents(dirname(__FILE__) . "/tmp3.txt", $abc . "\n", FILE_APPEND)?>2.原创 2012-05-24 18:49:47 · 422 阅读 · 0 评论 -
修改PHP的配置参数 去掉PHP的中警告等提示
1.修改配置文件中这条语句:error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR注:以上配置是我个人使用的默认设置。参数:(参考配置文件注释); Error Level Constants:; E_ALL - All errors and warning原创 2012-05-25 10:02:52 · 653 阅读 · 0 评论 -
取子串的正则表达式 (php)
一.问题:有如下字符串:"name1name2"用正则表达式如何取出"name1"和"name2"呢?二.解答:2.1:<?php $str="name1name2"; preg_match_all("/([^]*)/",$str,$matches); echo $matches[1][0]; echo $matches[1][1];?>转载 2012-10-11 10:06:35 · 1974 阅读 · 0 评论