Data Literals Supported in PHP

This section describes data literals to specify values for different data types: reserved key words; decimal, octal and hexadecimal numbers; floating point number format; single quoted, double quoted, and heredoc strings.

Data literals are ways to provide values for different data types in PHP source code. PHP data literals rules are summarized below:

1. boolean data literals: Data literals for boolean data type are two reserved key words: true and false. Note that true and false are case in-sensitive - TRUE and FALSE are also valid boolean literals.

2. integer data literals: Data literals for integer data type have 3 forms:

3. float data literals: Data literals for float data type are numeric values represented in signs and decimal digits with a decimal point and or exponential part. For example: 3.14159, 3e8, -1.25e-2, ...

4. string data literals: Data literals for string data type have 3 forms:

$monthDays = array("Jan"=>31,"Feb"=>28,"Mar"=>31);

5. array data literals: There are no data literals for array data type. Arrays are created by using the array constructor, array() function, or the array element notation, $arrayName[$key].

6. object data literals: There are no data literals for object data type. Objects are created by class constructors.

7. resource data literals: There are no data literals for resource data type. Resources are created by using PHP built-in functions.

8. null data literal: Data literal for null data type is 1 reserved key words: null. Note that null is case in-sensitive - NULL is the same as null.

Last update: 2015.

Table of Contents

 About This PHP Tutorial Book

 Introduction and Installation of PHP 5.6.6

 PHP Script File Syntax

PHP Data Types and Data Literals

 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

 Variables, References, and Constants

 Expressions, Operations and Type Conversions

 Conditional Statements - "if" and "switch"

 Loop Statements - "while", "for", and "do ... while"

 Function Declaration, Arguments, and Return Values

 Arrays - Ordered Maps

 Configuring and Sending out Emails

 Retrieving Information from HTTP Requests

 Creating and Managing Sessions in PHP Scripts

 Sending and Receiving Cookies in PHP Scripts

 Controlling HTTP Response Header Lines in PHP Scripts

 MySQL Server Connection and Access Functions

 Functions to Manage Directories, Files and Images

 SOAP Extension Function and Calling Web Services

 SOAP Server Functions and Examples

 Localization Overview of Web Applications

 Using Non-ASCII Characters in HTML Documents

 Using Non-ASCII Characters as PHP Script String Literals

 Receiving Non-ASCII Characters from Input Forms

 "mbstring" Extension and Non-ASCII Encoding Management

 Managing Non-ASCII Character Strings with MySQL Servers

 Introduction of Class and Object

 Integrating PHP with Apache Web Server

 Outdated Tutorials

 References

 PDF Printing Version