我在注释行上看到了这个错误。知道为什么吗?
Fatal error: Call-time pass-by-reference has been removed in myfile.php on line 301
Call Stack
# Time Memory Function Location
1 0.0002 245352 {main}( ) ../plugins.php:0
2 0.3016 7149968 plugin_sandbox_scrape( ) ../plugins.php:156代码如下...
function rseo_doTheParse($tag, $post){
//headings
$keyword = rseo_sanitize3(trim(strtolower(rseo_getKeyword($post))));
$content = rseo_sanitize3($post->post_content);
$match = 0;
$token = '/<'.$tag.'[^>]*>(.*\b'.$keyword.'\b.*)<\/'.$tag.'>/siU';
if(preg_match($token, &$content, $matches)) //THIS IS LINE 301
{
$match = 1;
}
return $match;
}发布于 2012-10-25 03:58:00
从&$content中删除&,它是通过引用传递的调用时间。
PHP长期以来一直支持passing arguments by reference;从历史上看,这可以通过声明函数通过引用接收参数来实现:
function foo(&$argument) { ... }
foo($value); // pass by reference或者在调用点使用按引用传递:
function foo($argument) { ... }
foo(&$value); // call time pass by reference后一个选项在PHP 5.4中已被删除,这是导致错误的原因。
发布于 2012-10-25 04:31:18
Jon是对的,你必须删除'&‘。为了获得更好的样式,PHP只允许对定义它的函数进行按引用传递,而不允许代码调用该函数。在http://php.net/manual/en/language.references.pass.php中有更多的细节,在您的例子中,您根本不需要它,因为执行结果无论如何都会被推送到这个变量。这并不直观,但是一些核心PHP函数就是这样运行的
https://stackoverflow.com/questions/13056733
复制相似问题