PHP data types

不言
不言Original
2018-05-02 09:14:121978browse

The content of this article mainly introduces the data types of PHP, which has certain reference value. Now I share it with everyone. Friends in need can refer to it

There are eight data types in PHP


  • can be divided into three categories

  1. Scalar: floating point, integer, character String, Boolean

  2. Composite: array, object

  3. Special: null, resource

  • Floating point types must not be used in equality judgments. There will be loss when the computer converts to binary calculations


  • Boolean type

  • False seven situations: 0, 0.0, ' ', '0', false, array()//empty array, NULL

  • ##Array type

Super global array $GLOBALS, $_GET, $_POST, $_REQUEST, $_SESSION, $_COOKIE, $_SERVER , $_FILES, $_ENV

Detailed explanation of $_SERVER: http://php.net/manual/zh/reserved.variables.server.php

    ##NULL three types Situation: Direct assignment to NULL, undefined variables, variables destroyed by unset
  • Constant
  • Definition method: const, define

    define('P1',"hello");    const P2 = "world";

const is faster, it is a language structure, define is a function; const can be used for the definition of class constants, define cannot

Related recommendations:

php Data types and conversions What are the data types of PHP? What are the data types of PHP?

The above is the detailed content of PHP data types. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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