PHP Classes

If you are going to set the variable "private $localiza;" mak...

Recommend this page to a friend!

      Find IP  >  All threads  >  If you are going to set the variable...  >  (Un) Subscribe thread alerts  
Subject:If you are going to set the variable...
Summary:Package rating comment
Author:simon ball
Date:2010-08-24 17:54:39

simon ball rated this package as follows:

Utility: Bad
Consistency: Good

  1. If you are going to set the variable...   Reply   Report abuse  
Picture of simon ball simon ball - 2010-08-24 17:54:39
If you are going to set the variable "private $localiza;" make a method to actual get it. I use a similar function on a SystemComponent of the site framework I use. Considering scale of use and when it would be used I would say for efficiencies sake, the following might be a little better for efficiencies sake:

public function GetIPAddress(){
// Check ip from share internet
if (!empty($_SERVER['HTTP_CLIENT_IP'])) { return $_SERVER['HTTP_CLIENT_IP']; }
// to check ip is pass from proxy
// In default case, return standard remote address

Then I only use this routine rarely so it can be like this with no worries. If it was to be used regularly, a method to actual set the "$localiza" would work a lot better than directly setting it for maintenence sake.

Consider if you were to even change the name of "$localiza", you would have to edit the code in more than just one place rather than the set method.

Peace and thanks for uploading to PHP-Classes. I hope this message is considered constructive criticism :)

For more information send a message to info at phpclasses dot org.