Re: isset()
| From: | Steve Edberg | Date: | Thu, 22 Feb 2001 16:18:22 +0000 |
| Subject: | Re: isset() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-41174@lists.php.net to get a copy of this message | ||
I would do this:
if (!$AgeChild) $AgeChild = 'NA';
More compact, easier to read (to me, anyway). This presumes that a value of '' (empty string, interpreted by PHP as false) is NOT a valid value here.
As far as your sniplet goes, it is possible that there may be some PHP type-casting issues here, depending on: whether $AgeChild is numeric or string; the fact that the STRING "false" isn't equivalent to the CONSTANT false, the use of == vs. ===.
Time to check out the docs - specifically the types and variables sections (also the functions->variables section)...
- steve
At 5:07 PM -0600 2/22/01, Jacky@lilst wrote:
People I tried to check if teh field has set a vaule in it before submit using isset with the sniplet below if ((isset($AgeChild))=="false") { $AgeChild = "NA"; } The resule is that it always displays NA whether or not it has vaule in the field, what is the correct way of using isset for this purpose? Or should I use empty() ? Jack jacky@activelifestyle.com "There is nothing more rewarding than reaching the goal you set for yourself"-- +--- "They've got a cherry pie there, that'll kill ya" ------------------+ | Steve Edberg University of California, Davis | | sbedberg@ucdavis.edu Computer Consultant | | http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ | +-------------------------------------- FBI Special Agent Dale Cooper ---+