title: function to get user IP address in Yii
body: <p>I'm trying to create a s shortcut to get user IP address, I created this function below in <strong>protected/helpers/shortcut.php</strong></p>
  
  <pre><code>echo getIP();
  function getIP()
  {
      return CHttpRequest::getUserHostAddress();
  }
  </code></pre>
  
  <p>i get this error because i set my php.ini to strict. and getUserHostAddress() is not a static function</p>
  
  <pre><code>Strict Standards: Non-static method CHttpRequest::getUserHostAddress() should not be called statically in /Applications/XAMPP/xamppfiles/htdocs/dev/protected/helpers/shortcuts.php on line 97
  ::1
  </code></pre>
  
  <p>i tried</p>
  
  <pre><code>Yii::app()-&gt;request-&gt;userHostAddress;
  </code></pre>
  
  <p>but i get this error</p>
  
  <pre><code>Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/dev/protected/helpers/shortcuts.php on line 97
  </code></pre>
  
  <p>any idea what i'm doing wrong? Thanks</p>