让自己陷入了困境。我们的主机已将 php 升级到 5.4,我们仍在一个通过引用将参数传递给函数的类中运行一些代码(我们没有编写),它看起来像这样:
$func_args = '';
// Make $row[0], $row[1] accessible by using $C1, $C2 etc.
foreach ($row as $k => $v)
{
${'C'.($k+1)} = $v;
$func_args .= "&\$C".($k+1).",";
}
// Give the user a chance to tweak the results with any function of their choice
// tweak functions are registered with $ez_results->register_function('func_name');
if ( is_array($this->tweak_functions) )
{
// Tweak results with each registered function
foreach ( $this->tweak_functions as $tweak_function )
{
// If function C1, C2, etc exists then run it
if ( function_exists($tweak_function) )
{
eval("$tweak_function(".substr($func_args,0,-1).");");
}
}
}
函数在此处的类中进一步注册:
var $tweak_functions = array('tweak_results');
function register_function($function_name)
{
$this->tweak_functions[] = $function_name;
}
这些函数在外部 PHP 文件中定义,如下所示:
function results_manipulation($news_id,$news_name,$news_seoname,$news_date2,$news_summary,$news_article,$news_url,$image_name,$image_thumb,$news_categories)
{
global $i;
if(!empty($image_thumb) && $i < 3 && empty($_GET['pg']) ){
$image_thumb = '<div class="newsthumb" style="background-image:url('.$image_thumb.')" title="'.$image_name.'"></div>';
}else{
$image_thumb = '';
}
$i++;
}
我查看了很多类似的问题,并试图找到一种方法来替换代码并保持一切正常,但没有任何成功。谁能指出我正确的方向?
非常感谢