I'm working on a plugin for WP but I am running into a PHP logic problem. Given $Var_check equals "1" and my_function does exist , what is wrong with my logical PHP statement below. It always echo's 'Always get this...' when it should actually return 'I should get this but...'
// Check to see if options are logical
if ( ($Var_check == "1") || ($Var_check == "6") && (function_exists('my_function'))) {
echo "I should get this, but...";
} else {
echo 'Always get this...'}
Is it my syntax? Any help would be very much appreciated.
I'm not much of a coder, but what I think is happening is that you're checking for:
Does $Var_check =1? OR Does $Var_check =1 AND is there a function called My_function?
Try this:
EDIT: mangled code, posting again
Or this:
<?php // Check to see if options are logical
function my_function() {
echo 'Hi';
}
$Var_check =1;
if ( (($Var_check == "1") || ($Var_check == "6")) && (function_exists('my_function'))) {
echo "I should get this, but...";
} else {
echo 'Always get this...';}
?>
Thanks for the reply. I had your version earlier and it didn't work. Sad. But I very much appreciate your response. I got frustrated and decided to take the query in another direction. Probably not as elegant, but it gets the job done.
Thanks again!