* Thus wrote Rasmus Lerdorf:
> 
> So, perhaps introduce the value() function which doesn't do any type
> casting and enhance the intval(), strval() and floatval() functions to act
> like value() but cast appropriately unless the default arg is returned.
> To retain backward compatibility the intval() function's default arg would
> have to be after the optional base arg.

If this route is taken, what about using the name nullval() to make
it fit into the naming schema? The prefix null implying no casting
will occur.

Going on the assumption:

unset($var);

echo intval($var);   //   0
echo strval($var);   //  ""
echo floatval($var); //0.00
echo nullval($var);  //null

$var = 1;
echo intval($var);   //   1
echo strval($var);   // "1"
echo floatval($var); //1.00
echo nullval($var);  //   1

or

$var = "1";
echo nullval($var);  // "1"


Although, i think that the intval()'s base option complicates
things a little.


Curt
-- 
First, let me assure you that this is not one of those shady pyramid schemes
you've been hearing about.  No, sir.  Our model is the trapezoid!

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to