php
  • if-statement
  • 2017-05-09 1 views -1 likes 
    -1

    if/else PHP 문에서 AND/OR에 문제가 있습니다. 특히 다음 코드 중 하나입니다.if/else 문에서 AND/OR가 작동하지 않습니다.

    if(is_page_template('page-home.php') || ('zaadvokati.php')) { 
    $class_trans = 'class="trans-color standard-menu"'; 
    }else{ 
    $class_trans = 'class="not-page-home standard-menu"'; 
    } 
    

    /OR, 지정된 두 개의 템플릿뿐만 아니라 첫 번째 class_trans 옵션을 가진 모든 템플릿을로드하고 OR 대신 AND를 넣으면 첫 번째 클래스 ('page-home.php')를 첫 번째 class_trans 두 번째 파일 ('zaadvokati.php')을로드하지 않습니다. 어떤 이유로 든 두 번째 템플릿을 인식하지 못하는 것 같지만 그 이유는 모르겠습니다.

    도와 주시겠습니까?

    감사합니다.

    답변

    0

    이 조건에서 함수를 반복해야합니다. 사용해보기 :

    if(is_page_template('page-home.php') || is_page_template('zaadvokati.php')) { 
        $class_trans = 'class="trans-color standard-menu"'; 
    }else{ 
        $class_trans = 'class="not-page-home standard-menu"'; 
    } 
    
    관련 문제