Press "Enter" to skip to content

241 search results for "php"

Apache Access Log中的Options的含义

说是, 在Apache的Access Log中会看到很多如下的访问日志:

127.0.0.1 - - [05/May/2011:10:54:07 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:08 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:09 +0800] "OPTIONS * HTTP/1.0" 200 -
127.0.0.1 - - [05/May/2011:10:54:10 +0800] "OPTIONS * HTTP/1.0" 200 -

这是什么意思呢?

Filed in Linux/Unix
with 8 Comments

Serialize/Unserialize破坏单例

我们经常采用如下方式定义单列:

class Singleton {
    private static $instance = NULL;
    /** 不容许直接调用构造函数 */
    private function __construct() {
    }
    /** 不容许深度复制 */
    private function __clone() {
    }
    public static function getInstance() {
        if (NULL === self::$instance) {
        	self::$instance = new self();
		}
        return self::$instance;
    }
}

很多人都会记得对深度copy的保护, 但, 其实我们却疏忽了一点...

Filed in PHP应用, 随笔
with 15 Comments

Expect:100-continue

在使用curl做POST的时候, 当要POST的数据大于1024字节的时候, curl并不会直接就发起POST请求, 而是会分为俩步,

  1. 发送一个请求, 包含一个Expect:100-continue, 询问Server使用愿意接受数据
  2. 接收到Server返回的100-continue应答以后, 才把数据POST给Server
  

Filed in PHP应用, 随笔
with 20 Comments

Compilation failed: support for \P, \p, and \X has not been compiled

首先感谢DiaHosting给我赞助了一个免费的VPS.
今天我终于把blog(WordPress)迁移到了新的VPS上, 由于环境的不一致(原来是Apache+mod_php, 现在是lighttpd+php_cgi), 中间出现不少问题, 但都没啥可说的.
一直到遇到如下这个问题:

Compilation failed: support for \P, \p, and \X has not been compiled
at offset 16 in /***/search-everything.php on line 802

Filed in PHP应用
with 7 Comments

如何获取一个变量的名字

比如, 我提供一个查询服务, 用户可以提交一个人的名字和年龄做为查询条件.
假设我要查询一个名字叫做"laruence", 年龄是27的人, 我认为这个人的定义的查询token可以写做:

   laruence=27

不幸的是, 当这样的一个token做为query string提交给服务器的处理脚本的时候, 你就会发现, 诶,,我不知道用户名是什么,,,
那么能否在PHP中获取到一个变量的名字呢?

Filed in PHP应用, PHP源码分析
with 20 Comments

[转载]技术文化和惨淡命运 —— 怀念中国雅虎

很早就想写这么一篇文章了。我离开中国雅虎已经一年有余,在中国雅虎工作的那段时光是我最珍贵的回忆之一,和以前的同事吃饭聊天的时候也经常会怀念一下中国雅虎,怀念得多了,就觉得不如写篇文章好好回顾一下。很多事情虽然已经过去,但有些话不说出来,到底意难平。
转载说明 :我的紫色情结. --作者是我以前小组的同事

Filed in 转载, 随笔
with 40 Comments

ReflectionFunction(Method)引用参数导致Invocation failed

今天同事反馈一个问题, PHP5.2.x在使用反射做函数包装的时候, 得到"Invocation failed"的异常, 而使用call_user_func代替则不会,
原逻辑太复杂, 经过精简以后可重现异常的代码如下(使用ReflectionFunction为例, ReflectionMethod类似):

function who(&$name) {
    echo $name;
}
$name = "laruence";
$method = new ReflectionFunction("who");
$method->invokeArgs(array($name));
//异常:
Uncaught exception 'ReflectionException' with message
'Invocation of function who() failed'

Filed in PHP应用, PHP源码分析
with 8 Comments

Can't find what you're looking for? Try refining your search: