RE: [PHP] alternative to empty
May be you can try (string)$string or (int)$string (seemed a little strange). Any way Ross, we need to see ur code to determine your problem. Best regards, Shiqi Yang -Original Message- From: Philip Hallstrom [mailto:[EMAIL PROTECTED] Sent: Thursday, July 07, 2005 12:15 AM To: Dan Rossi Cc: Ross; php-general@lists.php.net Subject: Re: [PHP] alternative to empty I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. If ($string == '') ?? Careful... notice the differenec b/n == and === ?php $s = 0; if ($s == '') { print(==\n); } if ($s === '') { print(===\n); } ? % php foo.php == % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
Hi, On 7/6/05, Ross [EMAIL PROTECTED] wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. Is there an alternative that will just check for empty strings. I suppose I could just use eregi and check for numbers but thought there may be a function that would work in a similar way. R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php http://www.php.net/manual/en/types.comparisons.php Very usefull !! I'll suggest you to print this out for quick reference. Salud! pancarne. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] alternative to empty
I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. Is there an alternative that will just check for empty strings. I suppose I could just use eregi and check for numbers but thought there may be a function that would work in a similar way. R. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
On 06/07/2005, at 7:55 PM, Ross wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. If ($string == '') ?? or if (isset($string)) ?? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
On Wed, 2005-07-06 at 10:55 +0100, Ross wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. Is there an alternative that will just check for empty strings. I suppose I could just use eregi and check for numbers but thought there may be a function that would work in a similar way. R. If a string is empty, it should be == '' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
what about checking that the length is 0 but i think the other suggestions are fine. André Medeiros wrote: On Wed, 2005-07-06 at 10:55 +0100, Ross wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. Is there an alternative that will just check for empty strings. I suppose I could just use eregi and check for numbers but thought there may be a function that would work in a similar way. R. If a string is empty, it should be == '' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
On Wed, 2005-07-06 at 20:23 +1000, Dan Rossi wrote: On 06/07/2005, at 7:55 PM, Ross wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. If ($string == '') ?? or if (isset($string)) ?? $string may be defined and still be empty ;) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
On Wed, 2005-07-06 at 13:20 +0200, Angelo Zanetti wrote: what about checking that the length is 0 Checking if length 0 requires calling a function, wich takes longer (it's a ridiculous difference, but still...) but i think the other suggestions are fine. André Medeiros wrote: On Wed, 2005-07-06 at 10:55 +0100, Ross wrote: I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. Is there an alternative that will just check for empty strings. I suppose I could just use eregi and check for numbers but thought there may be a function that would work in a similar way. R. If a string is empty, it should be == '' -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
On 06/07/2005, at 10:47 PM, André Medeiros wrote: If ($string == '') ?? or if (isset($string)) ?? $string may be defined and still be empty ;) Hence my first example :P -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] alternative to empty
I have been using empty in forms for some time now. but have just discovered that PHP 4 As of PHP 4, The string value 0 is considered empty. If ($string == '') ?? Careful... notice the differenec b/n == and === ?php $s = 0; if ($s == '') { print(==\n); } if ($s === '') { print(===\n); } ? % php foo.php == % -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php