title: Warning: First parameter must either be an object or the name of an existing class
body: <p>I'm Trying Some Codes for Getting User Location on My site But i have facing some issues i can't under stand what to do please anyone can solve my problem </p>
  
  <p>i'm trying </p>
  
  <pre><code>function curl($url){
  
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  $uaa = $_SERVER['HTTP_USER_AGENT'];
  curl_setopt($ch, CURLOPT_USERAGENT, "User-Agent: $uaa");
  
  return curl_exec($ch);
  
  }
  $ip = $_SERVER['REMOTE_ADDR'];
  $ipdat = @json_decode(curl("http://www.geoplugin.net/json.gp?ip=" . $ip));
  //get ISO2 country code
  if(property_exists($ipdat, 'geoplugin_countryCode')) {
  $local_visit = $ipdat-&gt;geoplugin_countryCode;
  }
  
  echo $local_visit;
  </code></pre>
  
  <p>And I'm facing error </p>
  
  <blockquote>
    <p>Warning: First parameter must either be an object or the name of an existing class <strong>public/visitor.php</strong> on line 17</p>
  </blockquote>
  
  <pre><code>line 17: if(property_exists($ipdat, 'geoplugin_countryCode')) {
  </code></pre>
  
  <p>how can i solve this issue or anyother source to get visitor country code for blocking some countries</p>
  
  <p>Thanks in advance</p>