How do you check if a variable is set or not in PHP?
It is important to note that if the variable is defined but set to 0 then it will still return 1.
<?php
function checksetting($var) {
if(isset($var)) { echo "Set"; } else { echo "Not set"; }
}
$a = 5; $b = 0;
checksetting($a); //set
checksetting($b); //set
?>
More strings PHP Questions
How do I replace a word in a string in PHP?How can I repeat a string variable several times?
How do I find the length of a string in PHP?
How do I check if a string contains HTML?
What is the difference between print and echo?