samedi 19 mai 2018

Nested IF conditions with multiple logic operators (AND, OR)

This is my first question on stackoverflow and hopefully somebody, beside me, needs this type of code.

The code I've written is working fine, but I would like to know how it can be improved or if there is a better way to achieve the same result.

// Do NOT include files for '404' and pages 'abc' or 'def' with slug '123'
if (  $pageName !== '404'  ) 
{ 

    if (( $pageName == 'abc' ) && ( $pageSlug == '123' ) 
             OR ( $pageName == 'def' ) && ( $pageSlug == '123' )) {

        return NULL;

    }

    else {

        // include file
        require_once ( '/file.php' );

        // Do NOT include for page 'def'
        if ( $pageName !== 'def' ) {

            // include file
            require_once ( file_2.php' );

        }

    }

};

Aucun commentaire:

Enregistrer un commentaire