PHP警告:implode():传递的参数无效

Roa*_*ode 1 php wordpress logging implode

我每次访问我的wordpress网站时都会在apache日志中收到此警告:

[错误] [client myiphere] PHP警告:implode():在第16行的/var/www/mysitepath/wp-content/themes/mytheme/noscript/views/list-view.php中传递的参数无效,参考文献:http: //www.example.com/

这是list-view.php的一部分:

<?php
$mytheme = mytheme::getInstance();
$currentContentLayout = $mytheme->WPData['currentContentLayout'];
$contentLayout = $mytheme->settings->contentLayouts->{$currentContentLayout};
$headerClasses = array();
if('no' == $contentLayout->metaPosition){
    $headerClasses = 'no-meta';
} else {
    $headerClasses[] = 'meta-' . $contentLayout->metaPosition;
}
?>
<div class="mytheme-list-view row">
    <div class="large-12 columns">
        <?php while(have_posts()){ the_post();?>
        <article id="post-<?php the_ID();?>" <?php post_class();?> data-mytheme-post-from-id="<?php the_ID();?>">
            <header class="entry-header <?php echo implode(' ', $headerClasses);?>">
...
...
Run Code Online (Sandbox Code Playgroud)

代码有什么问题吗?谢谢

rne*_*ius 5

您需要更改此行:

$headerClasses = 'no-meta';
Run Code Online (Sandbox Code Playgroud)

对此:

$headerClasses[] = 'no-meta';
Run Code Online (Sandbox Code Playgroud)

$headerClasses是字符串时会出现问题,因为implode()将数组作为第二个参数.