警告:缺少参数错误

时间:2012-02-12 18:01:30

标签: php arguments

我收到以下错误消息:

  

警告:调用了slider_getinfo_by_term()缺少参数7   /home/content/51/8870051/html/asan/wp-content/plugins/unpointzero-slider/Slider.php   在第37行并在中定义   /home/content/51/8870051/html/asan/wp-content/plugins/unpointzero-slider/upzSlider.php   在第207行

本页

http://autisticadvocacy.uniongraphics.org/

我已经查看了有关此问题的其他帖子,所以我明白这可能是一个语法问题(在某个地方缺少结束标记?),但我不知道如何修复它。

Slider.php第37行的代码是

    if($taxoname!=null && $taxoname!=""){
$allinfos = slider_getinfo_by_term($taxoname,$term,     $slider_view_number,$slider_title_max_char,$slider_title_thumb_max_char,$slider_desc_max_char);
}
elseif (($slider_type==1) || ($slider_type==3))  {
$allinfos = slider_getinfo_by_cat($slider_cat_id,$slider_view_number,$slider_fetch,$slider_title_max_char,$slider_title_thumb_max_char,$slider_desc_max_char);
}else{
$allinfos = slider_getpages($slider_cat_id,$slider_view_number,$slider_title_max_char,$slider_title_thumb_max_char,$slider_desc_max_char);
}
第207行的

和upzSlider.php是

function slider_getinfo_by_term($taxoname, $term, $number, $fetch,$slider_title_max_char,$slider_title_thumb_max_char,$slider_desc_max_char) {
global $post;
global $intername; // used as term
global $taxonamesc; // taxonomy
global $usingshort;

   $myposts = get_posts("post_status=\"publish\"&$taxoname=\"$term\"&numberposts=$fetch");
$postok_number = 0;

foreach($myposts as $post) :
    if(has_post_thumbnail($post->ID)) {
    $post_perma[] = get_permalink($post->ID);
    // Rcuperation des options
    $title = "";
    $title = tronc_str(__($post->post_title),$slider_title_max_char);
    $post_title[] = $title;

    $thumb_title = "";
    $thumb_title = tronc_str(__($post->post_title),$slider_title_thumb_max_char);
    $post_thumb_title[] = $thumb_title;

    $content = "";
    $post_excerpt = get_option('slider-contentexrpt');
    if($post_excerpt==1) {
    $content = tronc_str(__($post->post_excerpt),$slider_desc_max_char);
    }
    else {
    $content = tronc_str(__($post->post_content),$slider_desc_max_char);
    }
    $post_content[] = $content;

    $thumb[] =  get_the_post_thumbnail( $post->ID,'upz-big');

    $thumb_mini[] =  get_the_post_thumbnail( $post->ID,'upz-small');

        if(sizeof($post_title)==$number) {
        wp_reset_query();
        return array($post_perma,$post_title,$post_thumb_title,$post_content,$thumb,$thumb_mini);
        }       

    }
endforeach;
wp_reset_query();
return array($post_perma,$post_title,$post_thumb_title,$post_content,$thumb,$thumb_mini);
}

2 个答案:

答案 0 :(得分:3)

功能定义:

function slider_getinfo_by_term($taxoname, $term, $number, $fetch,$slider_title_max_char,$slider_title_thumb_max_char,$slider_desc_max_char)

函数调用:

slider_getinfo_by_term($taxoname,$term, $slider_view_number,$slider_title_max_char, $slider_title_thumb_max_char,$slider_desc_max_char);

比较定义 - >拨打:

$taxoname ->$taxoname
$term -> $term
$number -> $slider_view_number
$fetch -> $slider_title_max_char
$slider_title_max_char -> $slider_title_thumb_max_char
$slider_title_thumb_max_char -> $slider_desc_max_char
$slider_desc_max_char -> your error

我会说你的函数调用中缺少$fetch个参数,无论它是什么。)

编辑:$fetch分析:

您只在此行上使用$fetch

$myposts = get_posts("post_status=\"publish\"&$taxoname=\"$term\"&numberposts=$fetch");

所以我猜它的号码和你的函数调用应该是这样的:

$fetchNumber = 8; // Somewhere before your function call
slider_getinfo_by_term($taxoname,$term, $fetchNumber, $slider_view_number,$slider_title_max_char, $slider_title_thumb_max_char,$slider_desc_max_char);

答案 1 :(得分:0)

$allinfos = slider_getinfo_by_term($taxoname, $term, $slider_view_number, $slider_title_max_char, $slider_title_thumb_max_char, $slider_desc_max_char);

您错过了在$fetch$slider_view_number之间为$slider_title_max_char参数提供匹配变量。因此,只需在这两个变量之间,在原始函数中添加$fetch的预期变量。

类似的东西:

$allinfos = slider_getinfo_by_term($taxoname, $term, $slider_view_number, $some_variable_of_yours, $slider_title_max_char, $slider_title_thumb_max_char, $slider_desc_max_char);

这将解决您的问题。