2011-10-07 7 views
0
<?php 
if (get_option('to_breadcrumbs') == 'Yes'); 
if (get_option('to_breadcrumbs') != 'No') { 
    if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); 
} ?> 

저는 PHP에 상당히 익숙합니다. 위의 코드를 수정해야하는 것이 있습니까?if 문에 문제가 있습니까?

+1

예, 2 호선은 이해가되지 않습니다. 그걸로 뭘하고 싶니? – str

+0

그게 무엇입니까? 보이지 않는다. – John

+0

이 링크는 무엇입니까? http://stackoverflow.com/questions/7691953/php-to-show-by-default-call-or-array 그 답이 문제를 해결하지 못하면이를 허용으로 표시하지 마십시오. 대신 다른 것을 기다리십시오. –

답변

1

구문 상 올바릅니다.

if (get_option('to_breadcrumbs') == 'Yes'); 

이것은 필요하지 않습니다. 그것의 외부에서 실행되는 코드가 없습니다.

if (get_option('to_breadcrumbs') != 'No') { 
    if (function_exists('dimox_breadcrumbs')) dimox_breadcrumbs(); 
} 

이 실행하고 뭔가를 할 것입니다. 간단한 문장으로 줄일 수 있습니다.

if (get_option('to_breadcrumbs') != 'No' and function_exists('dimox_breadcrumbs')) 
    dimox_breadcrumbs(); 

위의 코드는 대부분의 PHP 프로그래머가 선호하지만 원하는대로 코딩 할 수 있습니다. 나는 이런 식으로 작성된 것

+0

'get_option ('to_breadcrumbs')'는 wordpress에서 옵션 필터를 실행하고 실제로 코드를 실행하지만 비교는 필요하지 않습니다. – hakre

1

if (get_option('to_breadcrumbs') == 'Yes'); 

이 이해가되지 않습니다 두 번째 줄, 그것은 전화 get_option() 제외하고 아무것도하지 않습니다 -하지만 조건이 작용하지 않습니다.

나머지는 내가 구문이 올바른지 생각

2

(. 기능이 실제로 물론을 무엇을 모르고) 제정신 보이지만 논리는 옳지 않다. get_option('to_breadcrumbs') != 'No'은 값이 yes 또는 no 일 수 있다고 가정하고 get_option('to_breadcrumbs') == 'Yes'과 같습니다.

+0

그들은 두 개의 다른 진술입니다. –

0

:

<?ph 
//I'm assuming here that only you only want to run it if the to_breadcrumbs option is equal to yes. 
if(get_option('to_breadcrumbs') == 'Yes' AND function_exists('dimox_breadcrumbs')){ 
    dimox_breadcrumbs(); 
} 
?>