我得到當前的日期時間,但沒有得到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()是否已經設置或不設置。但是我已經設置了它,這使我感到困惑。非常感謝鏈接 –
如果您在本地主機上工作,則此功能不起作用。在遠程服務器上嘗試此代碼。 –