PHP Tutorials - Herong's Tutorial Examples
Dr. Herong Yang, Version 3.00

PHP Data Types and Data Literals

This chapter provides tutorial notes and example codes on PHP data types and data literals. Topics include 8 data types supported in PHP; data literals to provide data values in PHP code for different data types; integer and float value overflow conditions.

Data Types Supported in PHP

Data Literals Supported in PHP

Data Literals Examples for Integer, String and Other Data Types

Overflow of Integer and Float Values

Conclusion:

  • PHP supports 8 data types: boolean, integer, float, string, array, object, resource, null.
  • PHP integer data type uses the 32-bit signed integer storage format.
  • PHP float data type uses the 64-bit floating-point number storage format, the IEEE 754 double-precision standard.
  • PHP sting data type uses the 8-bit byte storage format.
  • PHP array data type uses key-value pairs to manage array elements. PHP arrays are really associate arrays, maps or hash tables in other programming languages.
  • PHP handles integer value overflow conditions by automatically converting results to float data type.
  • PHP handles float value overflow conditions by automatically converting results to "infinite" or 0.

Dr. Herong Yang, updated in 2009
PHP Data Types and Data Literals