根据以下代码如果$host_name
是这样的example.com
PHP 返回一个通知:Message: Undefined index: host
但在完整的网址上,例如http://example.com
PHP 返回example.com
。我尝试使用 FALSE 和 NULL 的 if 语句,但没有成功。
$host_name = $this->input->post('host_name');
$parse = parse_url($host_name);
$parse_url = $parse['host'];
如何修改脚本以接受 example.com 并返回它?
升级你的 php.ini5.4.7 Fixed host recognition when scheme is ommitted and a leading component separator is present.
手动添加方案:if(mb_substr($host_name, 0, 4) !== 'http') $host_name = 'http://' . $host_name;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)