Re: [Fwd: PHP Peer - Benchmark - timer.php]

From: Date: Sat, 13 Sep 2003 16:05:21 +0000
Subject: Re: [Fwd: PHP Peer - Benchmark - timer.php]
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-21473@lists.php.net to get a copy of this message
Sebastian Bergmann wrote:
    function getOutput($set_http=null)
    {
        if (function_exists('version_compare') &&
            version_compare(phpversion(), '4.1', 'ge'))
        {
            $http = isset($_SERVER['SERVER_PROTOCOL']);
        } else {
            global $HTTP_SERVER_VARS;
            $http = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']);
        }
        if (!is_null($set_http))
        	$http = $set_http;
I don't know what this is doing, but I would do it as:
     function getOutput($set_http=null)
     {
         if (!is_null($set_http)) {
             $http = $set_http;
         } else {
             if (function_exists('version_compare') &&
                 version_compare(phpversion(), '4.1', 'ge'))
             {
                 $http = isset($_SERVER['SERVER_PROTOCOL']);
             } else {
                 global $HTTP_SERVER_VARS;
                 $http = isset($HTTP_SERVER_VARS['SERVER_PROTOCOL']);
             }
         }
     }
No sense in doing all of that checking if you're just going to overwrite it. -- Marshall Roch http://pear.php.net/user/mroch

« previous php.pear.dev (#21473) next »