Re: changing NULL behavior in PHP arithmetic
| From: | Shawn McKenzie | Date: | Sat, 17 Apr 2010 01:41:17 +0000 |
| Subject: | Re: changing NULL behavior in PHP arithmetic | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-304152@lists.php.net to get a copy of this message | ||
On 04/15/2010 02:46 AM, cr.vegelin@gmail.com wrote:
> Hi All,
>
> Is there an option in PHP to change the behavior of NULL in PHP functions ?
> Now PHP uses NULL as a 0 (zero) for arithmetic, for example:
> NULL + 6 = 6
> NULL * 6 = 0
> NULL / 6 = 0
> 6 / NULL = Division by zero
>
> What I need is the same behavior as #N/A (or =NA()) in Excel, where:
> #N/A + 6 = #N/A
> #N/A * 6 = #N/A
> #N/A / 6 = #N/A
> 6 / #N/A = #N/A
>
> because arithmetic operations with "Unknown" operands should result to
> "Unknown" ...
>
> TIA, Cor
>
In what cases do you have a null var?
--
Thanks!
-Shawn
http://www.spidean.com