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.
1 Answer
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.