Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to treat the PHP function isset () can only be used for variables

2025-04-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

Today, I will talk to you about how to treat the PHP function isset () can only be used for variables, many people may not know much about it. In order to make you understand better, the editor has summarized the following for you. I hope you can get something according to this article.

By learning the PHP language, you should know that it is a function-based HTML scripting language. The huge function library supports the implementation of PHP language functions. Next we introduce you to the related usage of the PHP function isset ().

Format: bool isset (mixed var [, mixed var [,...]])

Function: detect whether the variable is set

Return value:

Return FALSE if the variable does not exist

If the variable exists and its value is NULL, it also returns FALSE

If the variable exists and the value is not NULL, TURE is returned

When multiple variables are checked at the same time, TRUE is returned only if each item meets the previous requirement, otherwise the result is FALSE

Version: PHP 3, PHP 4, PHP 5

For more information:

After you release the variable using unset (), it will no longer be isset ().

The PHP function isset () can only be used for variables, and passing any other parameters will result in a parsing error.

The defined () function can be used to detect whether the constant is set.

< ?php $var = ''; if (isset($var)) // 空值、0、false 的赋值结果均被isset判为 TRUE,所以后边 的文本将被打印出来。 print "blank value ->

Isset = true. "

Var = NULL;if (! isset ($var)) / /

NULL will be judged as FALSE by isset

Print "NULL value-> isset = false."

/ / the following uses var_dump to output the return value of isset ().

$a = "test"

B = "anothertest"

Var_dump (isset ($a)); / / TRUE

Var_dump (isset ($a, $b); / / TRUE

Unset ($a)

Var_dump (isset ($a)); / / FALSE

Var_dump (isset ($a, $b); / / FALSE

? >

The PHP function isset () is also suitable for checking array elements and object elements. If the array or object instance is not defined, the array element / object element detected will be returned false.

< ?php $a = array ('test' =>

1, 'hello' = > NULL); var_dump (isset ($a [' test'])); / / TRUE var_dump (isset ($a ['foo'])); / / FALSE var_dump (isset ($a [' hello'])); / / FALSE / / key 'hello' is equal to NULL, so it is considered unset. / / if you want to detect the NULL key, you can try the following method. Var_dump (array_key_exists ('hello', $a)); / / TRUE? >

Note: because this is a language construct rather than a function, the PHP function isset () cannot be called by a variable function.

After reading the above, do you have any further understanding of how to think that the PHP function isset () can only be used for variables? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report