2015-04-06 37 views
0

我想要parts/lesson-links.php不包括在get_the_lesson_contenttype()等于“提示”“主要课程”为什么这个PHP if语句仍然包含里面的内容?

所以我这样做:

<h2><?php echo get_the_lesson_contenttype(); ?></h2> 

    <?php if (get_the_lesson_contenttype() != 'Hints' || get_the_lesson_contenttype() != 'Main Lesson') { ?> 
    <?php 
     include(locate_template('parts/lesson-links.php')); 
    ?> 
    <?php } ?> 

但你可以在这个页面中看到:http://clo2015.chineselearnonline.com/lessoncontent/lesson-004-hints-and-tips/

parts/lesson-links.php仍在增加。我做错了什么?

编辑:

奇怪的是它的工作原理没有||,只增加Hint

<?php if (get_the_lesson_contenttype() != 'Hints') include(locate_template('parts/lesson-links.php'));?> 
+0

这将永远是事实。 'get_the_lesson_contenttype'不能是两个值。了解'AND'和'OR'之间的区别。 – PeeHaa 2015-04-06 02:53:58

+0

@PeeHaa所以我应该写什么呢? – alexchenco 2015-04-06 02:56:03

+1

我想你想'if(get_the_lesson_contenttype()!='Hints'&& get_the_lesson_contenttype()!='Main Lesson'){?>'。这样一来,只有当它不是“提示”而且它不是“主要课程”时才会包含它。 – chris85 2015-04-06 02:57:13

回答

2

你混了你ANDSORS(双关语意(我不好笑))

<h2> 
    <?php echo get_the_lesson_contenttype(); ?> 
</h2> 

<?php 
    if (get_the_lesson_contenttype() != 'Hints' && get_the_lesson_contenttype() != 'Main Lesson') { 
     include(locate_template('parts/lesson-links.php')); 
    } 
?> 

让我们看看一些布尔操作!在这里,我们gooooo .....

你说......

我想零件/课,links.php时get_the_lesson_contenttype()等于“提示”或“主要教训没有被列入”。

恩那就像...

if (get_the_lesson_contenttype() == "Hint" || get_the_lesson_contenttype() == "Main Lesson") 
    DONT INCLUDE 

ACTIVATE否定!!!!!!! (基本翻转一切!)

if (get_the_lesson_contenttype() != "Hint" && get_the_lesson_contenttype() != "Main Lesson") 
    DOOOO INCLUDE