以技术为主
php
defined() isset()和function_exists()的用法
一 25th
defined()判断一个常量是否定义
isset()判断一个变量是否定义
function_exists判断一个函数是否定义
file_exists判断一个文件是否存在
关于php优化的好文
一 19th
A HOWTO on Optimizing PHP
PHP is a very fast programming language, but there is more to optimizing PHP than just speed of code execution.
In this chapter, we explain why optimizing PHP involves many factors which are not code related, and why tuning PHP requires an understanding of how PHP performs in relation to all the other subsystems on your server, and then identifying bottlenecks caused by these subsystems and fixing them. We also cover how to tune and optimize your PHP scripts so they run even faster.
Achieving High Performance
When we talk about good performance, we are not talking about how fast your PHP scripts will run. Performance is a set of tradeoffs between speed versus accuracy versus scalability. An example of speed versus accuracy is your scripts might be tuned to run fast with caching, but the data will tend to grow stale and be less accurate. For an example of speed versus scalability you could write a script that runs fast by loading everything into memory, or write a more scalable one that only loads data in chunks so that it does not exhaust application memory (Updated 30 Oct 2009 from speed vs scalability to speed vs accuracy vs scalability).
In the example below, A.php is a sprinter that can run fast, and B.php is a marathon runner than can jog forever at the nearly the same speed. For light loads, A.php is substantially faster, but as the web traffic increases, the performance of B.php only drops a little bit while A.php just runs out of steam.
http://phplens.com/lens/php-book/optimizing-debugging-php.php 具体请参看
比较三款免费的PHP加速器:APC vs eAccelerator vs XCache
一 18th
一、PHP加速器介绍
PHP加速器是一个为了提高PHP执行效率,从而缓存起PHP的操作码,这样PHP后面执行就不用解析转换了,可以直接调用PHP操作码,这样速度上就提高了不少。
Apache中使用mod_php的请求、响应执行流程:
1、Apache接收请求。
2、Apache传递请求给mod_php。
3、mod_php定位磁盘文件,并加载到内存中。
4、mod_php编译源代码成为opcode树。
5、mod_php执行opcode树。 更多 >
php-rest常用框架
一 13th
1. Konstrukt
- 开发语言: PHP
- 操作系统: 跨平台
- 软件主页: http://konstrukt.dk/
- 文档地址: http://konstrukt.dk/apidocs.html
- 下载地址: http://konstrukt.googlecode.com/files/konstrukt-0.4.zip
2.Tonic
3.dbscript
4,cakephp
附:详细介绍REST服务http://www.yaronspace.cn/blog/index.php/archives/383
php–debug_zval_dump函数用法
一 3rd
今天学到的函数:debug_zval_dump查看某个变量的引用计数
debug_zval_dump — Dumps a string representation of an internal zend value to output
说明
Dumps a string representation of an internal zend value to output.
关于php中的引用计数和分离的介绍,推荐:http://www.laruence.com/2008/09/19/520.html
写得很详细的
php实现函数可变参数列表
十二 6th
今天在看wordpress源码时,发现这个用法的,分享之。
主要是利用func_get_args()、func_num_args()、func_get_arg()这三个系统函数来实现的,具体用法参看手册
代码如下:
<?php
/**
* 函数的多参数列表的实现
*
*/
function multiArgs()
{
/** 以数组的形式返回参数列表 */
$args = func_get_args();
/** 参数的个数 */
$args_num = func_num_args();
foreach ( $args as $key => $value )
{
echo ‘This is ‘,$key+1,’th argument:’,$value,’<br/>’;
}
echo ‘Number of args is ‘,$args_num;
}
multiArgs(‘one’,'two’,'three’);/** output */
/**
This is 1th argument:one
This is 2th argument:two
This is 3th argument:three
Number of args is 3
*/
?>
php–register_shutdown_function()
十二 6th
修改php文件的扩展名-apache配置
十一 10th
下面一行代码是apache配置的一个技巧,通过在自定义的.htaccess或者httpd.conf中添加一行就可以将xml文件作为php文件来解析。当然你也可以添加其他的扩展名文件来作为php文件来解析。当你想用到动态生成xml文件时就会用到下面的代码了
AddType application/x-httpd-php .php .xml
注意:不同的web server配置可能有稍有差别
利用php中的zlib库的ob_gzhandler函数实现页面压缩包括css和js
十一 4th
为了提升性能,页面在服务器端利用gzip算法进行压缩,基本大部分站点都是这么做的,但是这部分工作一般是交给了apache服务器本身来做的,其实也可以利用php本身zlib库来实现对页面的压缩,但这仅仅是一个替代方案,效率上肯定没前一种好的,下面主要介绍下用这种方案的实现方式。
1,压缩php文件:只要在页面的最开始部分加上如下代码即可:
< ?php if(extension_loaded(‘zlib’)) {ob_start(‘ob_gzhandler’);} ?>
ob_start(“ob_gzhandler”)这句话的意思是首先将页面放到缓冲区中,然后利用库函数ob_gzhandler对页面内容进行gzip的压缩,最后把页面输出。当然必须先判断是否装有这个扩展了 更多 >

近期评论