What Does " If(True) " Means? [Closed]
I'm Building a Functionality Which Displays a Message Dynamically, I. E If the Forms Are Correctly Filled or Not. I Came Across This Piece of Code and I Don't...
I'm building a functionality which displays a message dynamically, i.e if the forms are correctly filled or not. I came across this piece of code and I don't understand how does it really work.
if(true) {
$this->flash('Yay ! File uploaded successfully', 'success');
} else {
$this->flash('There is some error', 'error');
From what I've already looked for, I guess it's used to see whether or not there is an array available, since PHP returns false if there isn't one. (according to PHP manual ) I still don't get how does this work, there is no variables such as if($foo) but just plain boolean on this condition.
And yes, it seems to work as intended.
Thanks for your enlightments.
This looks like a debugging statement left in.
if(true)
This is always true, so you could remove the test entirely and just run with the true statement.