Skip to content

Instantly share code, notes, and snippets.

@dbergey
Created October 8, 2010 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbergey/617401 to your computer and use it in GitHub Desktop.
Save dbergey/617401 to your computer and use it in GitHub Desktop.
<?php
function a() {
echo "Called A.\n";
return false;
}
function b() {
echo "Called B.\n";
return true;
}
a() && b();
?>
@dbergey
Copy link
Author

dbergey commented Oct 8, 2010

b() is never called because a() returned false. Good to know that PHP lazily evaluates.

@dbergey
Copy link
Author

dbergey commented Oct 8, 2010

What it DOESN'T do is return the value of the truey expression when using ||.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment