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 view and judge PHP data types

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

Share

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

This article mainly shows you "how to view and judge PHP data type", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to view and judge PHP data type" this article.

Viewing and judging of PHP data types viewing data types

In learning, we can carry out different operations according to different data types, so how to view a data type is particularly important. We know the type of a data before we can proceed to the next step. Next, I'll introduce you to two functions that view data types.

Gettype (passing in a variable) can get the type of variable

If you pass in a declared variable in gettype, you can pass out the variable type of that variable, as an example:

Output result:

Thus, gettypt () can get the variable type of the variable, but it needs to be displayed by echo, so is there a function that can directly output the variable type?

Var_dump (passing in a variable) outputs variants and values

Var_dump can output not only the variable type of the variable, but also the value of the variable. Examples are as follows:

Output result:

Thus, var_dump () can directly output not only the variable type of the variable, but also the value of the variable.

Determine the data type

In daily use and learning, we should not only look at the data types of variables, but also be able to judge. There are not many data types of variables, and it is very simple to judge, so you need to use a series of is_* functions.

It is called a series function because it does not exist alone, and since you want to determine whether something is a type or not, it often appears with the type of variable that needs to be judged.

If this type returns true, not this type returns false.

Whether is_bool () is Boolean

If the variable is Boolean, the return result is true and the output true interval; if the variable is not Boolean, the return result is false and the output false interval.

Output result:

The output is: study hard. The output true interval, the return result is true, the variable is Boolean.

Whether is_null is empty

If the variable is empty, the return result is true and the output true interval; if the variable is not empty, the return result is false and the output false interval.

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