我得到当前的日期时间,但没有得到IP地址....输出是:: 1 ..为什么发生这种情况? enter image description here没有得到codeigniter的IP地址
<?php
defined('BASEPATH') or exit('No Direct Script Access Allowed');
class Ip_address extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('url');
}
public function index(){
// var_dump($_SERVER);
$this->load->helper('date');
echo $date = "Current Time Is: ". date('Y-m-d H:i:s');
echo "<br/>";
echo $this->input->ip_address();
}
}
Posiible duplicate https://stackoverflow.com/questions/10517371/ip-address-of-the-machine-in-php-gives-1-but-why –
非常感谢。我看过一些贴子告诉我检查base_url()是否已经设置或不设置。但是我已经设置了它,这使我感到困惑。非常感谢链接 –
如果您在本地主机上工作,则此功能不起作用。在远程服务器上尝试此代码。 –