Re: function_exists question

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Matt Pagel wrote:
> Is there a way to check not only if a function exists, but also to check
> that the number and types of parameters desired match a function
> definition?
> 
> The reason being that additional options have been added in php 4 and 5
> to various standard function calls, but I'm still running a php3 and
> php4 server in addition to a php5 server.  I would like to make sure
> that certain "extended" function calls still work in all versions (or
> I'll perform the tasks "manually", albeit less efficiently).
> 
> One example I can think of is the round() function.  The $precision
> parameter was added in php4, so will not work in php3.  However,
> function_exists would return TRUE for both 3 and 4, but round itself
> would fail if I tried to send a precision level to the php3 server.
> 
> Thanks much,
> Matt
> 
> P.S. Of course the modified "function_exists" would unfortunately have
> to be a recognized function/method in php3 in order for me to call it to
> check parameter counts on a php3 server :(

Unless I misunderstand you, why not just execute based upon the version
or some similar approach?  Actually, I can't even find any version 3
docs, so maybe I should bow out?

// Only needed if PHP_VERSION is not included in version 3, I dunno
if (!defined('PHP_VERSION')) { define('PHP_VERSION', '3'); }

if (PHP_VERSION < 4) {
	$num = round(101.11);
} else {
	$num = round(101.11, 0);
}

As I type this I think:  if you're going to use the script on v3, 4 and
5, then why would you use the second parameter?  You'll get a whole
number returned on v3 so why would you want a fractional returned on
other versions?

-- 
Thanks!
-Shawn
http://www.spidean.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux