用GDB调试PHP程序[转] 03月28日
转载自:http://www.sulabs.net/?p=40
我们先想办法重现一下Segmentation fault现象,下面我们先使用Shell的方式来试验,编写demo.sh脚本:
#!/bin/bash
kill -s SEGV $$
其中$$就是脚本的进程号,SEGV信号的作用等同于Segmentation fault,整句基本意思就是让自己崩溃。
保存好,并且加上执行权限:chmod +x demo.sh (更多…)
memcache和memcached之间的区别和联系【转】 07月11日
由于在项目后期会引入缓存策略对角色的数据进行缓存,而现在我们大部分缓存都使用文件缓存,开发过网页游戏的朋友们大都知道,语言包和游戏相关的数 据大部分不经常改动,有时候几个星期不需要更新,只是在进行版本更新的时候才重新生成一次数据缓存,而角色的数据和数值时刻在变化着,会频繁的更新和操 作,采用文件缓存会频繁地进行I/O操作,在这个功能上文件缓存就不太适合了,所以对于角色的数据采取内存缓存策略在这里就比较合适。
对于内存缓存,比较常用的有两种memcache和memcached扩展。而memcached和memcache的守护进程memcached同名, 比较容易引起混淆,甚至提到memcached,有些人第一想到的是后台的守护进程,这里还是有必要分析一下两者之间的区别,以下观点仅是个人观点,希望 朋友进行补充和更正。
首先我们可以从php官方手册上可以清晰的看到两者的区别:
memcache:http://cn2.php.net/manual/en/book.memcache.php
memcached:http://cn2.php.net/manual/en/book.memcached.php
memcache是完全在PHP框架内开发的,memecached是使用libmemcached的。从手册上看,memcached 会比 memcache 多几个方法,使用方式上都差不多。 (更多…)
PHP5.4改变的新特性(未完待续) 07月04日
PHP5.4改变的特性
20 Jun 2011, PHP 5.4.0 Alpha 1
- autoconf 2.59+ is now supported (and required) for generating the
configure script with ./buildconf. Autoconf 2.60+ is desirable
otherwise the configure help order may be incorrect. (Rasmus, Chris Jones)
删除的特性:
. break/continue $var syntax. (Dmitry)
. Safe mode and all related ini options. (Kalle) //删除安全模式相关的所有函数和配置
. register_globals and register_long_arrays ini options. (Kalle) //删除这两个函数配置文件中的内容
. import_request_variables(). (Kalle) //
. allow_call_time_pass_reference. (Pierrick)
. define_syslog_variables ini option and its associated function. (Kalle)
. highlight.bg ini option. (Kalle)
. Session bug compatibility mode (session.bug_compat42 and
session.bug_compat_warn ini options). (Kalle)
. session_is_registered(), session_register() and session_unregister()
functions. (Kalle)
. y2k_compliance ini option. (Kalle)
- Moved extensions to PECL: (Johannes) //sqlite 被移动到PECL中
. ext/sqlite. (更多…)
利用Curl、socket、file_get_contents POST数据 05月16日
/** * Socket版本 * 使用方法: * $post_string = "app=socket&version=beta"; * request_by_socket('facebook.cn','/restServer.php',$post_string); */ function request_by_socket($remote_server,$remote_path,$post_string,$port = 80,$timeout = 30){ $socket = fsockopen($remote_server,$port,$errno,$errstr,$timeout); if (!$socket) die("$errstr($errno)"); fwrite($socket,"POST $remote_path HTTP/1.0"); fwrite($socket,"User-Agent: Socket Example"); fwrite($socket,"HOST: $remote_server"); fwrite($socket,"Content-type: application/x-www-form-urlencoded"); fwrite($socket,"Content-length: ".strlen($post_string)+8.""); fwrite($socket,"Accept:*/*"); fwrite($socket,""); fwrite($socket,"mypost=$post_string"); fwrite($socket,""); $header = ""; while ($str = trim(fgets($socket,4096))) { $header.=$str; } $data = ""; while (!feof($socket)) { $data .= fgets($socket,4096); } return $data; }
/** * Curl版本 * 使用方法: * $post_string = "app=request&version=beta"; * request_by_curl('http://facebook.cn/restServer.php',$post_string); */ function request_by_curl($remote_server,$post_string){ $ch = curl_init(); curl_setopt($ch,CURLOPT_URL,$remote_server); curl_setopt($ch,CURLOPT_POSTFIELDS,'mypost='.$post_string); curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); curl_setopt($ch,CURLOPT_USERAGENT,"Jimmy's CURL Example beta"); $data = curl_exec($ch); curl_close($ch); return $data; } ?>
/** * 其它版本 * 使用方法: * $post_string = "app=request&version=beta"; * request_by_other('http://facebook.cn/restServer.php',$post_string); */ function request_by_other($remote_server,$post_string){ $context = array( 'http'=>array( 'method'=>'POST', 'header'=>'Content-type: application/x-www-form-urlencoded'."". 'User-Agent : Jimmy's POST Example beta'."". 'Content-length: '.strlen($post_string)+8, 'content'=>'mypost='.$post_string) ); $stream_context = stream_context_create($context); $data = file_get_contents($remote_server,FALSE,$stream_context); return $data; } ?>
php技术大会2011 05月08日

2011-05-07,在北京长城饭店参加完了2011年php技术大会,这个算是中国php的最高技术论坛吧,到场的人大概有1000多,当然,百度、腾讯、淘宝、新浪等大公司来的人应该超过了一半。php,这个顶着中国70%左右的互联网流量的编程语言,神奇的把大家聚合在了一起。
回到我的技术博客 03月11日
这段时间什么都不想想,上次写日志是在过年的时候,转眼间已经一个月过去了。
生活就是这样,在迷茫中思考,也许,这个过程很艰难,但是,这也是成长。
从现在开始,我的博客将转入一个技术博客,我将记录我所有的技术历程。
河马归来