I have field value $copyContent which, when dumping returns:
"true"
It's actually boolean filed which I am pulling out trough request from endpoint like:
'/api/copy/6?copy_content=true'
I want to check that if it's true or it's false. I tried:
if ($copyContent === "TRUE") {
echo 'Do it!'
} else {
echo 'Do not do it!'
}
and also just:
if ($copyContent)
or:
if ($copyContent === true)
Non of this examples work as it should. Can you tell what am I doing wrong?
Update:
I tried with:
if (filter_var($copyContent, FILTER_VALIDATE_BOOLEAN)) {}
This works.. Can this be suitable solution?
Aucun commentaire:
Enregistrer un commentaire