Home » Php » false / FALSE — any difference?

false / FALSE — any difference?

Posted by: admin November 29, 2017 Leave a comment

Questions:

I noticed that some PHP frameworks use exclusively lowercase true/false and others upper.

Does it make any difference at all? I for one prefer lowercase.

Answers:

No difference, some people consider FALSE to be a constant and thus use the old screaming caps notation.

Questions:
Answers:

I know I’m late to the party here, but I’ll just quote the documentation in case anybody wants an authoritative answer, as I did.

To specify a boolean literal, use the constants TRUE or FALSE. Both are case-insensitive.

In fact, the example immediately following the above uses this fact:

$foo = True; // assign the value TRUE to $foo

PhP is biZarRe.

Questions:
Answers:

Well there is a difference but I don’t know what it is!

Returning FALSE instead of false in a form validation will not stop the form from being posted in chrome Version 27.0.1453.94 m so there must be a difference!

// Gets posted
//-----------------------------
function validate_form()
{
    alert("Here we are!!");
    return(FALSE);
}


// Form doesn't get posted (correct behavior)
//-----------------------------
function validate_form()
{
    alert("Here we are!!");
    return(false);
}