单数组排序
sort函数升序排序
单数组排序
sort函数升序排序
ftp_get() 函数从 FTP 服务器上下载一个文件。
若成功则返回 true,失败则返回 false。
举个例子,我们现在所在的时区是+8,那么服务器运行以下脚本返回的时间应该是这样的:
当前时间假定是2007-03-14 12:15:27
similar_text — 计算两个字符串的相似度
int similar_text ( string $first , string $second [, float &$percent ] )
$first 必需。规定要比较的第一个字符串。
$second 必需。规定要比较的第二个字符串。
$percent 可选。规定供存储百分比相似度的变量名。
/**
* 获取系统信息
*
* @return array
*/
function getSystemInfo()
{
$systemInfo = array();
// 系统
$systemInfo['os'] = PHP_OS;
// PHP版本
$systemInfo['phpversion'] = PHP_VERSION;
// Apache版本
$systemInfo['apacheversion'] = apache_get_version();
// ZEND版本
$systemInfo['zendversion'] = zend_version();
// GD相关
if (function_exists('gd_info'))
{
$gdInfo = gd_info();
$systemInfo['gdsupport'] = true;
$systemInfo['gdversion'] = $gdInfo['GD Version'];
}
else
{
$systemInfo['gdsupport'] = false;
$systemInfo['gdversion'] = '';
}
// 安全模式
$systemInfo['safemode'] = ini_get('safe_mode');
// 注册全局变量
$systemInfo['registerglobals'] = ini_get('register_globals');
// 开启魔术引用
$systemInfo['magicquotes'] = (function_exists("get_magic_quotes_gpc") && get_magic_quotes_gpc());
// 最大上传文件大小
$systemInfo['maxuploadfile'] = ini_get('upload_max_filesize');
// 脚本运行占用最大内存
$systemInfo['memorylimit'] = get_cfg_var("memory_limit") ? get_cfg_var("memory_limit") : '-';
return $systemInfo;
}
在写程序时发现在判断文件是否存在时,有两种写法,有的人用了is_file,有的人用了file_exists,用哪个更好或者说更合适呢?
判断文件存在用is_file还是file_exists?
round() 函数对浮点数进行四舍五入
语法
strtr(string,from,to)
或者strtr(string,array)
首先针对strtr函数第一种方式
我们看看下面的举例:
bool curl_setopt (int ch, string option, mixed value)
curl_setopt()函数将为一个CURL会话设置选项。option参数是你想要的设置,value是这个选项给定的值
简单说一下. microtime() 如果带个 true 参数, 返回的将是一个浮点类型. 这样 t1 和 t2 得到的就是两个浮点数, 相减之后得到之间的差. 由于浮点的位数很长, 或者说不确定, 所以再用个 round() 取出小数点后 3 位. 这样我们的目的就达到了~
了解crypt()
只要有一点使用非Windows平台经验的读者都可能对crypt()相当熟悉,这一函数完成被称作单向加密的功能,它可以加密一些明码,但不能反过来将密码重新转换为原来的明码。crypt()函数定义如下。
文件上传表单的处理