咕咚
  咕咚首页 | 个人秀 | 公开圈子 | 抽奖
  php欢迎您
圈子首页 | 成员列表 | 圈子论坛 | 文件共享 | 圈子相册 | 成员相册 | 成员博客 | 站内邀请
讨论区导航: php (4)
贴子列表    发表新贴 标准视图 树式浏览
   圈子讨论区 → php → 主题内容

Zandy
发送私信
加为好友
标题:[PHP4用]--自定义了几个php5才有的函数 发表于 2006-04-28 18:11:42
楼主
<?php

/**
* Filename : funtions_php5.php
* Author   : Dummy | Zandy
* Email    : lianxiwoo@gmail.com | hotmail.com
* Create   : 200603
* LastMod  : 2006
* Usage    : 
*/

if (!function_exists('debug_print_backtrace') && function_exists('debug_backtrace'
)){
    function 
debug_print_backtrace
(){
        
print_r(debug_backtrace
());
    }
}

if (!
function_exists('file_put_contents'
)){
    
defined('FILE_USE_INCLUDE_PATH') || define('FILE_USE_INCLUDE_PATH'1
);
    
defined('LOCK_EX') || define('LOCK_EX'2
);
    
defined('FILE_APPEND') || define('FILE_APPEND'8
);
    function 
file_put_contents($fileName$data$type null
){
        
$type $type == FILE_APPEND 'a' 'w'
;
        
$fp fopen($fileName$type
);
        
$type == LOCK_EX && flock($fp$type
);
        
fputs($fp$data
);
        
fclose($fp
);
        return 
strlen($data
);
    }
}

?>
回复

Zandy
发送私信
加为好友
发表于 2006-08-21 21:12:13
1楼

<?php

// author: Zandy

// {{{ 简单点的
if (!function_exists('curl_setopt_array'))
{
    function 
curl_setopt_array(&$ch$options)
    {
        foreach (
$options as $k => $v)
        {
            if (!
curl_setopt($ch$k$v))
            {
                return 
false;
            }
        }
        return 
true;
    }
}
// }}}

// {{{ 复杂点的
if (!function_exists('curl_setopt_array'))
{
    function 
curl_setopt_array(&$ch$options)
    {
        if (!
is_array($options)){
            
trigger_error('curl_setopt_array() expects parameter 2 to be array, null given 'E_USER_WARNING);
        }
        foreach (
$options as $k => $v) {
            if (!
curl_setopt($ch$k$v)) {
                return 
false;
            }
        }
        return 
true;
    }
}
// }}}

?>

回复
共1页  1 
关于咕咚 | 申请加盟 | 服务协议 | 招聘人才 | 广告服务 | 联系我们 | 本站地图
沪ICP备06045422号 Copyright @ 2005-2007 goodoon.com