In where shall I use isset() and !empty()

isset vs. !empty FTA: “isset() checks if a variable has a value including (False, 0 or empty string), but not NULL. Returns TRUE if var exists; FALSE otherwise. On the other hand the empty() function checks if the variable has an empty value empty string, 0, NULL or False. Returns FALSE if var has a … Read more

JavaScript isset() equivalent

I generally use the typeof operator: if (typeof obj.foo !== ‘undefined’) { // your code here } It will return “undefined” either if the property doesn’t exist or its value is undefined. (See also: Difference between undefined and not being defined.) There are other ways to figure out if a property exists on an object, … Read more

If isset $_POST

Most form inputs are always set, even if not filled up, so you must check for the emptiness too. Since !empty() is already checks for both, you can use this: if (!empty($_POST[“mail”])) { echo “Yes, mail is set”; } else { echo “No, mail is not set”; }

Php if($var) used to work [closed]

You didn’t get the error before, because your error_reporting and/or display_error settings were set too forgiving. Your first snippet is attempting to access a value in an array that might not exist. If it doesn’t PHP always issues a notice. It’s only after the notice has been issued that it can be hushed up (by … Read more