使用未定义的常数 [英] Use of undefined constant

查看:64
本文介绍了使用未定义的常数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的网站
中遇到此错误我的网站是wordpress 4
i使用发布格式
以发布格式我创建了这个php,如果页面有引用发布,则不要加载标题和图像等来自报价单的内容只是显示报价内容是meta框(wordpress)

Hi I have this error in my website my website is wordpress 4 i use post format in post format i create this php to if page has quote post then dont load title and image and etc from quote post just show quote content is meta box (wordpress)

Notice: Use of undefined constant quote - assumed 'quote' in C:\xampp\htdocs\personal\wp-content\themes\personal\warp\systems\wordpress\layouts\_post.php on line 4

Notice: Use of undefined constant quote - assumed 'quote' in C:\xampp\htdocs\personal\wp-content\themes\personal\warp\systems\wordpress\layouts\_post.php on line 14


这是下面的_post.php代码


this is _post.php code in bellow

<?php $format = get_post_format(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('group'); ?>>    
<?php
if ($format != quote ) { 
$css_class = "b-box"; 
} else { 
$css_class = "q-box"; 
}

echo "<div class=\"$css_class\">";  
?>
        <?php get_template_part('inc/post-formats'); ?>

        <?php if ($format != quote ) : ?>
        <div class="post-content">
            <div class="blog-img-box">
                <img src="<?php echo catch_that_image() ?>" alt="<?php the_title(); ?>" />
             </div>
    <div class="post-deco blog-icon-box">
            <div class="hex hex-small">
                <i class="fa blog-icon"></i>
                <?php if ( $format != false ) :?><a href="<?php echo get_post_format_link($format); ?>"></a><?php endif; ?>
            </div>
        </div><!--/.post-deco-->
        <h2 class="blog-title">
        <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a>
    </h2><!--/.post-title-->
             <div class="blog-details row">
                        <div class="col-md-4"><i class="fa fa-calendar blog-details-icons"></i>
                            <p class="blog-details-icons-txt"><?php the_time('j M, Y'); ?></p>
                        </div>
                        <div class="col-md-4">
                        <a href="<?php comments_link(); ?>">
                        <i class="fa fa-comment blog-details-icons"></i>
                           <p class="blog-details-icons-txt"><?php comments_number( '0', '1', '%' ); ?>&nbsp;Comments</p></a>
                        </div>
                        <div class="col-md-4"><i class="fa fa-eye blog-details-icons"></i>
                            <p class="blog-details-icons-txt"><?php echo getPostViews(get_the_ID()); ?></p>
                        </div>
                        <div class="likes"><i class="fa fa-heart blog-details-icons"></i>
                            <p class="blog-details-icons-txt">18</p>
                        </div>
                    </div>
                    <div class="blog-txt">
            <?php the_excerpt(); ?>
            </div>
            <a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><div class="readmore-box"><p class="readmore-txt"><?php _e('Read More','anew'); ?></p></div></a>
        </div><!--/.post-content-->
        <?php endif ?>
    </div><!--/.post-inner-->
</article><!--/.post--> 

请检查并告诉我我错了

谢谢!

推荐答案

如果要使用报价作为文字字符串(第4行),而不是变量名,必须将其括在单引号或双引号字符('

If you want to use the quote as a literal string (line 4), not a variable name, you must enclose it into single or double quote characters (' or "). Otherwise, PHP thinks that you're referencing a PHP constant.

出于向后兼容的原因,PHP退回了使用字符串作为原义的方法。 ,但确实会引发 E_NOTICE 错误-您遇到的错误。

For reasons of backward compatibility, PHP falls back on using the string as literal, but it does throw an E_NOTICE error – the one you're experiencing.

这篇关于使用未定义的常数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆