$ In php represents a variable, but how can I know the type of this variable? -Php Tutorial

Source: Internet
Author: User
$ In php represents a variable, but how can I know the type of this variable? $ In php represents a variable, but how can I know the type of this variable?


Reply to discussion (solution)

PHP provides six functions (boolean is_int (mixed variable), boolean is_float (mixed variable), boolean is_bool (mixed variable), and boolean is_string (mixed variable), boolean is_array (mixed variable), boolean is_object (mixed variable ))

You can use the gettype () function.
$ A = "hello ";
Echo gettype ($ );
?>

PHP provides six functions (boolean is_int (mixed variable), boolean is_float (mixed variable), boolean is_bool (mixed variable), and boolean is_string (mixed variable), boolean is_array (mixed variable), boolean is_object (mixed variable ))
However, when writing a php program, for example, is the type automatically changed based on the following parameters?
<? Php
$ A = 123;
$ B = True;
?>

Php is more time-consuming than judgment, but conversion.
$ A = "123 ";
$ B = True;
Var_dump ($ a * $ B );


PHP provides six functions (boolean is_int (mixed variable), boolean is_float (mixed variable), boolean is_bool (mixed variable), and boolean is_string (mixed variable), boolean is_array (mixed variable), boolean is_object (mixed variable ))
However, when writing a php program, for example, is the type automatically changed based on the following parameters?
<? Php
$ A = 123;
$ B = True;
?>
You are mistaken. $ is just a named symbol and does not represent the type. this is the PHP specification. The type is defined by yourself.
$ Arr = array (); // array
$ Str = '000000'; // string
...



PHP provides six functions (boolean is_int (mixed variable), boolean is_float (mixed variable), boolean is_bool (mixed variable), and boolean is_string (mixed variable), boolean is_array (mixed variable), boolean is_object (mixed variable ))
However, when writing a php program, for example, is the type automatically changed based on the following parameters?
<? Php
$ A = 123;
$ B = True;
?>
You are mistaken. $ is just a named symbol and does not represent the type. this is the PHP specification. The type is defined by yourself.
$ Arr = array (); // array
$ Str = '000000'; // string
...
By the way, what does this mean? It is difficult for me to find detailed information in the php Manual. please give me some advice.
Class foo {
Public $ bar = < Bar
EOT;
}
?>

This is your keyword for PHP under Baidu.

In fact, we should be more concerned about how the c parser knows what type?
I have participated in Baidu's interview. after the first round, I had a question in the second round: How do I know an array php parser?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.