Re: Package proposal: Net_Ip

From: Date: Fri, 30 May 2003 15:17:24 +0000
Subject: Re: Package proposal: Net_Ip
References: 1 2 3 4 5 6  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-16840@lists.php.net to get a copy of this message
> I did see it. As you might have noticed, I am not the one that you > replied to. sorry :] >> You have a construct like if () { return foo; } else { return bar; } >> retun baz; there, in the method to get the ip. [php] if (ereg($this->pattern, $realip, $ip_array)) { return $ip_array[0]; } elseif (isset($ip)) { return false; } return $_SERVER['REMOTE_ADDR']; [/php] what is wrong with this ? it's "elseif" not "else" The function is ok ... > Your pcre pattern lacks delimiters. And pcre is significantly faster > than ereg. 1 million times executed: hey, getting ip is used often only once in script :] but ok u are right, its slower :] > > do u really think that using > > > > Net_Ip::get(); > > > > is faster than > > > > $ip->get() > > I don't think, I know. ehh If u prefere making ur code more complex by addin everywhere [php] if (isset($this)) { $this->method(); } else { Class_name::method(); } [/php] ... do it .... but i think that this is unnecessary in most cases > > and what if i change class name ? i will have to change a lot of code ... > > If you need to change a class name, you have done something wrong. thats the point After coding a lot, u see that u did smth wrong, and have to change class name what do u do know ? I will simply change 1 line of code U will have to change XXX lines of code for example i have application which uses Net_Ip know u say that my package can go into PEAR but i have to change class name to Net_DetectIp what know ? There will be next releases, and if i want to use it in my application I would have to change a LOT of code ... :( k but lets not talk about it, i prefer calling objects, u calling statically classes both have advantages and disadvantages -- cagrET

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