<分区>
Possible Duplicate:
In PHP (>= 5.0), is passing by reference faster?
我想知道通过声明参数按引用传递,PHP 解释器是否会更快,因为不必将字符串复制到函数的本地范围? 该脚本将 XML 文件转换为包含数千条记录的 CSV,因此几乎没有时间优化。
这会不会:
function escapeCSV( & $string )
{
$string = str_replace( '"', '""', $string ); // escape every " with ""
if( strpos( $string, ',' ) !== false )
$string = '"'.$string.'"'; // if a field has a comma, enclose it with dobule quotes
return $string;
}
比这更快:
function escapeCSV( $string )
{
$string = str_replace( '"', '""', $string ); // escape every " with ""
if( strpos( $string, ',' ) !== false )
$string = '"'.$string.'"'; // if a field has a comma, enclose it with dobule quotes
return $string;
}
?