On Tue, Feb 19, 2013 at 9:29 PM, John Taylor-Johnston <john.taylor-johns...@cegepsherbrooke.qc.ca> wrote: > > What is the difference between? > > if (empty... http://www.php.net/manual/en/function.empty.php "Determine > whether a variable is empty" > and > if (isset... http://php.net/manual/en/function.isset.php "Determine if a > variable is set and is not *|NULL|*"
I like the explanation on the empty page: "No warning is generated if the variable does not exist. That means empty() is essentially the concise equivalent to !isset($var) || $var == false." > I have an <input type="radio" value="something">. > > If it is not checked, it is NOT empty, because it has a value, right? > But it is NOT set, right? Some of the form elements (e.g., checkboxes, radio's) are a little tricky: http://stackoverflow.com/questions/476426/submit-an-html-form-with-empty-checkboxes When unchecked, no GET or POST variable is present to represent their value. > Is this empty, because it's value is ""? > > <input type="text" value=""> > > Just trying to understand ... :) A text field would be present in the GET or POST super globals, and if empty (the user did not add input), the empty function would return true because an empty string is one of the values that evaluates to false: - "" (an empty string) - 0 (0 as an integer) - 0.0 (0 as a float) - "0" (0 as a string) - NULL - FALSE - array() (an empty array) - $var; (a variable declared, but without a value) Adam -- Nephtali: A simple, flexible, fast, and security-focused PHP framework http://nephtaliproject.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php