2015-04-06 34 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