gpt4 book ai didi

php - 检查 URL 中是否存在参数

转载 作者:塔克拉玛干 更新时间:2023-11-03 05:51:18 24 4
gpt4 key购买 nike

如何检查 URL 中是否包含参数?

例如,如果字符串是这样的,

form_page_add.php?parent_id=1

return true

但是如果是这样的话,

form_page_add.php?

return nothing

谢谢。

编辑:

抱歉不清楚,URL 是从一个字符串中提交的。我会将该字符串存储在一个变量中,

if(isset($_POST['cfg_path'])) $cfg_path = trim($_POST['cfg_path']);

所以我需要检查这个变量 $cfg_path 是否有参数。

最佳答案

也可以使用 array_key_exists() 查找特定键,例如

if(array_key_exists('some-key', $_GET))

http://php.net/manual/en/function.array-key-exists.php

关于php - 检查 URL 中是否存在参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5360014/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com