如何检查 $_GET 是否为空?

2022-01-04 00:00:00 get php

如何检查$_GET是否为空?

推荐答案

你自己说的,检查它是 empty:

You said it yourself, check that it's empty:

if (empty($_GET)) {
    // no data passed by get
}

看,PHP 就是这么简单.你可以简单地写下你的想法;)

See, PHP is so straightforward. You may simply write, what you think ;)

这种方法非常安全.如果 $_GET 未设置(不太可能,但可能),!$_GET 可能会给你一个未定义的变量 E_NOTICE.

This method is quite secure. !$_GET could give you an undefined variable E_NOTICE if $_GET was unset (not probable, but possible).

相关文章