最近更新服务器的nginx的版本,但在make后出现如下警告:
objs/src/os/unix/ngx_process.o: In function `ngx_process_get_status’:
ngx_process.c:(.text+0xc41): warning: `sys_errlist’ is deprecated; use `strerror’ or `strerror_r’ instead
ngx_process.c:(.text+0xc32): warning: `sys_nerr’ is deprecated; use `strerror’ or `strerror_r’ instead
在其官方网站回复是,这属正常现象,没有替换废弃的函数是因为新的为非异步信号安全的函数
A message “ ‘sys_errlist’ is deprecated; use ‘strerror’ or ‘strerror_r’ instead ”
今天用到basename 函数获取文件名称时,发现如果是中文的文件名返回只有后缀的空文件名(如:.pdf)
string basename ( string path [, string suffix] )
说明
给出一个包含有指向一个文件的全路径的字符串,本函数返回基本的文件名。如果文件名是以 suffix 结束的,那这一部分也会被去掉。
按照网站上找到说法是此函数依赖于区域设置,如果是多字节名称返回为空可以通过setlocale函数如下设置
<?php
setlocale(LC_ALL, 'zh_CN.UTF8');
// or any other locale that can handle multibyte characters.
?>
最好是修改服务器的区域设置来整体解决
isset() , unnset(), empty() 是一个语言结构而非函数,因此它无法被变量函数调用。
isset()、empty() 只检测变量,检测任何非变量的东西都将导致解析错误。后边的语句是错误而且将不会起作用: empty(addslashes($name))。 若想检测常量是否已设置,可使用 defined() 函数。同时要注意的是一个 NULL 字节(“\0″)并不等同于 PHP 的 NULL 常数。所以 isset(NULL)会发生语法错误。
像echo(),print(),include(),require() 都是语言结构而非函数。
其它参考:isset和is_null的不同
php对中文截取确实不好
<?php
//不错中英字符截取函数
function cut($Str, $Length) {//$Str为截取字符串,$Length为需要截取的长度
global $s;
$i = 0;
$l = 0;
$ll = strlen($Str);
$s = $Str;
$f = true;
while ($i <= $ll) {
if (ord($Str{$i}) < 0x80) {
$l++; $i++;
} else if (ord($Str{$i}) < 0xe0) {
$l++; $i += 2;
} else if (ord($Str{$i}) < 0xf0) {
$l += 2; $i += 3;
} else if (ord($Str{$i}) < 0xf8) {
$l += 1; $i += 4;
} else if (ord($Str{$i}) < 0xfc) {
$l += 1; $i += 5;
} else if (ord($Str{$i}) < 0xfe) {
$l += 1; $i += 6;
}
if (($l >= $Length - 1) && $f) {
$s = substr($Str, 0, $i);
$f = false;
}
if (($l > $Length) && ($i < $ll)) {
$s = $s . '...';
break; //如果进行了截取,字符串末尾加省略符号“...”
}
}
return $s;
}
$test="zivee - 徐只好";
echo cut($test,10);
?>