根据以下代码 if $host_nameis something like example.comPHP 返回一个 notice:Message: Undefined index: host但在完整的 URL 上,如http://example.comPHP 返回example.com。我尝试了带有 FALSE 和 NULL 的 if 语句,但没有奏效。
$host_name = $this->input->post('host_name');
$parse = parse_url($host_name);
$parse_url = $parse['host'];
如何修改脚本以接受 example.com 并返回它?