I’m not sure why I can’t get this to work:
A super simple function that just needs to return true or false:
<?php
function check_for_header_images() {
if ( file_exists('path/to/file') && file_exists('path/to/file'))
return true;
}
?>
It will not return true:
<?php
if(check_for_header_images()) {
// do stuff
}
?>
…doesn’t do stuff:
<?php
if(!check_for_header_images()) {
// do stuff
}
?>
…does do stuff.
The conditions I’ve set for the function SHOULD return true. If I take that same exact if statement and just do this:
<?php
if ( file_exists('path/to/file') && file_exists('path/to/file')) {
//do stuff
}
?>
It works.
Do I just not understand how to write a function?
or you could do:
also, the
!in your if statement means opposite. that meansif (!false)is true, andif (!true)is false