圈子讨论区 → 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; } } // }}}
?>
|
| 回复 |
|
|
|