Identifiers in php

An identifier is simply a name. In PHP, identifiers are used to name variables, functions, constants, and classes. The first character of an identifier must be an ASCII letter (up-percase or lowercase), the underscore character (_), or any of the characters between ASCII 0x7F and ASCII 0xFF. After the initial character, these characters and the digits 0–9 are valid

Variable names

Variable names always begin with a dollar sign ($) and are case-sensitive. Here are some valid variable names

Here are some illegal variable names:

$not valid
$|
$3wa

These variables are all different due to case sensitivity:

$hot_stuff $Hot_stuff $hot_Stuff $HOT_STUFF

Function names

Function names are not case-sensitive.Here are some valid function names:

tally
list_all_users
deleteTclFiles
LOWERCASE_IS_FOR_WIMPS
_hide

These function names refer to the same function:

howdy HoWdY HOWDY HOWdy howdy

Class names

Class names follow the standard rules for PHP identifiers and are also not case-sensitive. Here are some valid class names:

Person
account

The class name stdClass is reserved

Constants

A constant is an identifier for a simple value; only scalar values—Boolean, integer, double, and string—can be constants. Once set, the value of a constant cannot change. Constants are referred to by their identifiers and are set using the define() function:

define(‘PUBLISHER’, “O’Reilly & Associates”);
echo PUBLISHER;

Leave a Comment