少しピクルスになりました。私たちのホストは 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++;
}
私は多くの同様の質問を見て、コードを置き換えてすべてを機能させ続ける方法を見つけようとしましたが、成功しませんでした。誰かが私を正しい方向に向けることができますか?
どうもありがとう