我有一个 HTML 表单字段$_POST["url"]
,有一些 URL 字符串作为值。
示例值是:
https://example.com/test/[email protected]
https://example.com/test/[email protected]
https://example.com/test/[email protected]
https://example.com/test/[email protected]&testin;=123
https://example.com/test/the-page-here/[email protected]
etc.
我怎样才能只得到email
来自这些 URL/值的参数?
请注意,我没有从浏览器地址栏中获取这些字符串。
您可以使用parse_url() and parse_str()为了那个原因。
$parts = parse_url($url);
parse_str($parts['query'], $query);
echo $query['email'];
如果您想获得$url
动态地使用PHP,看看这个问题:
获取 PHP 中的完整 URL
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)