yiic error

I like to display user IP (WANIP) in the upper right corner of the webpage, so I put

<?php echo $_SERVER['REMOTE_ADDR'] ?>

in the .../protected/views/layouts/main.php

after that yiic does not work

gives error:

PHP error

Undefined index: REMOTE_ADDR

if I delete this line (or comment it out), yiic works…

In command line mode this variable isn’t set. So maybe try:

<?php echo isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : '' ?>

I solved it by using userHostAddress

<?php echo Yii::app()->request->userHostAddress; ?>

your code works too…