Home > Backend Development > PHP Tutorial > PHP 5 data types

PHP 5 data types

WBOY
Release: 2016-07-29 08:58:19
Original
1131 people have browsed it

  • String (string), Integer (integer), Float (floating point), Boolean (Boolean), standard types
  • Array (array), Resource (resource type)
    -Object, NULL
  • PHP string
    You can put any text in single and double quotes;
    Single quotes do not parse variables, double quotes parse variables

  • PHP integer
    An integer is a number without decimals.
    Integer rules:
    Integer must have at least one digit (0-9)
    Integers cannot contain commas or spaces
    Integers have no decimal point
    Integers can be positive or negative
    Integers can be specified in three formats: decimal, hexadecimal (prefixed by 0x), or octal (prefixed by 0).

  • PHP Floating Point

    Floating point numbers are numbers with a decimal part, or in exponential form.

  • PHP Boolean

    Boolean can be TRUE or FALSE.
    x=true;y=false;
    Boolean type is usually used for conditional judgment.

  • PHP Arrays

    Arrays can store multiple values ​​in one variable

  • PHP Objects

Object data types can also be used to store data.
In PHP, objects must be declared.
First, you must declare the class object using the class keyword. Classes are structures that can contain properties and methods.
Then we define the data type in the class and then use the data type in the instantiated class:
Example

<code><span><?php</span><span><span>class</span><span>Car</span>
{</span><span>var</span><span>$color</span>;
  <span><span>function</span><span>Car</span><span>(<span>$color</span>=<span>"green"</span>)</span> {</span><span>$this</span>->color = <span>$color</span>;
  }
  <span><span>function</span><span>what_color</span><span>()</span> {</span><span>return</span><span>$this</span>->color;
  }
}
<span>?></span></span></code>
Copy after login

In the above example, the PHP keyword this is a pointer to the current object instance and does not point to any other object or class.

  • PHP NULL value

NULL value means the variable has no value. NULL is a value of data type NULL.
The NULL value indicates whether a variable has a null value. It can also be used to distinguish between data null values ​​and NULL values.
You can clear variable data by setting the variable value to NULL:

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

The above introduces the PHP 5 data types, including aspects of the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template