Home > Backend Development > PHP Tutorial > parse_url返回值的有关问题

parse_url返回值的有关问题

WBOY
Release: 2016-06-13 12:01:45
Original
1152 people have browsed it

parse_url返回值的问题

<br />$parse_url = parse_url($page_info['url'])['scheme'];报错<br /><br />//看手册说parse_url()返回一个关联数组,报错是什么问题,必须要这样吗:<br />$parse_url = parse_url($page_info['url']);<br />$scheme = $parse_url['scheme'];<br />
Copy after login

------解决方案--------------------
parse_url() 是一个函数,函数后面你跟[]能行吗?
------解决方案--------------------
parse_url($page_info['url'])['scheme'] 只在 php5.4 起才可以用
------解决方案--------------------
你的PHP版本太低了
------解决方案--------------------
php 版本低,不支持這種寫法。
個人覺得第二種寫比較清晰。
------解决方案--------------------
版本的原因,升级到5.4
------解决方案--------------------
5.4的版本有有什么问题?

哪种写法好些,这的因人而异,不做评价
不过你在 js 中不都是那么写吗?
------解决方案--------------------
echo PHP_VERSION; //5.4.20<br />$page_info['url'] = 'http://aaa.main.com';<br />echo $parse_url = parse_url($page_info['url'])['scheme']; //http
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template