Variables, References, and Constants
This chapter provides tutorial notes and example codes on PHP variables, references, and constants. Topics include how to name variables; assigning data values to variables; creating the reference of a variable; using variable variable names; using string expressions as variable names; defining constant names to values; retrieving the value from a constant.
Variables and Assignment Operations
References and Variables
Variable Variable Name - Name Variables with Expressions
Constant and define() Function
- PHP variables are typeless. Values of different data types can be assigned to the same variable.
- PHP variable names starts with $ sign.
- & operator returns the reference of a variable.
- The reference of a variable can be assigned to a new variable to make an alias to the original variable.
- A variable name can represented as a string expression. This is called variable variable name.
- Functions define() defines a constant with the constant name and the constant value.
- Only scalar data type values can be used as constant values.
Table of Contents
About This Book
Introduction and Installation of PHP 7.0
PHP Script File Syntax
PHP Data Types and Data Literals
►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
PDF Printing Version