Found answer, see below. Delete this. False or true equates to false using Local for my test environment

What issue or error are you experiencing?

Using Local for my local test environment within a PHP block, the OR is not working.
For some reason (false or true) equates to false.
(true or false) equates to true.

swapping the next two lines changes the value. I can not figure out why unless Local has a bug.

$bDisplayChildPageLinks = true or false;
$bDisplayChildPageLinks = false or true;
echo ‘dcpl:’.($bDisplayChildPageLinks?‘TRUE’:‘false’).‘*’;

The entire context is below:

<?php $iPagePostID = get_the_id(); echo '-'.$iPagePostID.'*'; $iParentPostID = wp_get_post_parent_id($iPagePostID); echo '-'.$iParentPostID.'*'; // get the parent's id (0=no parent). $bIsChildPage = $iParentPostID != 0; echo '-'.($bIsChildPage?'TRUE':'false').'*'; // 0 = no parent page. $sParentLink = get_permalink($iParentPostID); $sParentTitle = get_the_title($iParentPostID); // 0 = current page = title of current page. echo 'cp:'.($bIsChildPage?'TRUE':'false').'*'; $aaChildPages = array('child_of' => $iPagePostID); // Argument for get_pages(). //d echo $aaChildPages; $asChildPages = get_pages($aaChildPages); // returns a collection of child pages or Null if none. //d echo $asChildPages; $bIsParentPage = $asChildPages != NULL; echo 'pp:'.($bIsParentPage?'TRUE':'false').'*'; $bDisplayChildPageLinks = $bIsChildPage or $bIsParentPage; ////// This is always false????? $bDisplayChildPageLinks = true or false; $bDisplayChildPageLinks = false or true; echo 'dcpl:'.($bDisplayChildPageLinks?'TRUE':'false').'*'; --- ### What steps can be taken to replicate the issue? Feel free to include screenshots, videos, etc $bDisplayChildPageLinks = true or false; $bDisplayChildPageLinks = false or true; echo 'dcpl:'.($bDisplayChildPageLinks?'TRUE':'false').'*'; swapping the two lines changes the value although both should be true. --- ### System Details * **Local Version:** 9.0.2+6676 * **Operating System (OS) and OS version:** Windows 11 --- ### Local Logs Attach your Local Logs here ([Help Doc - Retrieving Local's Log](https://localwp.com/help-docs/troubleshooting/retrieving-locals-log-file/)) [local-logs.zip|attachment](upload://sHhVxtrKWoMFtQvm2FOP94FWb08.zip) (37.0 KB) --- ***Security Reminder*** Local does a pretty good job of scrubbing private info from the logs and the errors it produces, however there's always the possibility that something private can come through. Because these are public forums, always review the screenshots you are sharing to make sure there isn't private info like passwords being displayed.

false || true equals true but
false or true equals false.

ANSWER:

$bResult = false or true; // equals false because the ‘or’ has less precedence then the equals.

One should use

$bResult = (false or true);

Or

$bResult = false || true;

Hi @Lladnar - So did those adjustments accomplish what you needed or do you still need some help here?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.