16

I have followed the exact guide that is provided on the official codeigniter website for running the CLI (command-line interface) tool. https://www.codeigniter.com/userguide2/general/cli.html

My controller is...

<?php
class Tools extends CI_Controller {

    public function message($to = 'World')
    {
    echo "Hello {$to}!".PHP_EOL;
    }

} ?>

When I run the following command from my CMD I get the following output (and error) in the command line window:

php index.php tools message

<h4>A PHP Error was encountered.</h4>
<p>Severity: Notice</p>
<p>Message: Undefined index: REMOTE_ADDR</p>
<p>Filename: core/Input.php</p>
<p>Line Number: 351</p>
.....
<h4>A PHP Error was encountered</h4>
<p>Message: Cannot modify header information - headers already sent by (output at C:{systempath}\system\2.1.4\core\Exceptions.php:185)</p>
<p>Filename: libraries/Session.php</p>
<p>Line Number: 675</p>

</div>Hello World!

Can anyone explain why I am getting this problem? I am following the tutorial as per the official Codeigniter CLI tutorial too - any ideas? I am using CodeIgniter 2.1.4 with XAMPP (Windows).

1 Answer 1

30

https://github.com/EllisLab/CodeIgniter/issues/1890

Just replace $_SERVER['REMOTE_ADDR'] with $this->server('remote_addr') at the line that generates the notice. - modify /system/core/Input.php line 351

Sign up to request clarification or add additional context in comments.

1 Comment

This seems to be the workaround - not sure why EllisLabs don't make this change to the core themselves though as I never touch the core directory normally.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.