On Thu, Apr 17, 2008 at 10:01:13AM -0400, Sam Barrow wrote:
> On Thu, 2008-04-17 at 14:52 +0200, Paul Biggar wrote:
> > just the copy in the callee - I think this is a good idea). As an
> > example, this will fail, which it shouldnt: function y (int $x) {
> > assert (is_int($x); } y ("24");
>
> The problem with this is that there's not much point in converting the
> value. PHP will do that anyway, making this kind of pointless.
If inside y() you have something like:
for( $i = 0; $i < $x; $i++ )
you will end up converting $x to integer $x times ... which will eat
CPU if $x is large -- I tried it.
An:
assert (is_int($x))
followed by:
$x = (int)$x
is the way to go.
> This only serves to include an additional type juggling system into php,
> which is very confusing.
If you don't understand it: don't use it.
--
Alain Williams
Linux Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer.
+44 (0) 787 668 0256 http://www.phcomp.co.uk/
Parliament Hill Computers Ltd. Registration Information:
http://www.phcomp.co.uk/contact.php
Chairman of UKUUG: http://www.ukuug.org/
#include <std_disclaimer.h>
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php