Google News
logo
PHP - Interview Questions
What is PHP Variables ?
PHP Variables are used for storing data such as numeric values, characters, character strings etc. All PHP variable names must be pre-fixed with a ( $). Variable names are case-sensitive they are ($var and $VAR are two different variables).

Syntax of declaring a PHP valid and invalid variable names :

$varName         // valid
$_varName       // valid
$__varname    // valid
$var_name       // valid
$varName21     // valid
$_var-Name  // invalid contains non alphanumeric character (-)
$_9Var  // invalid - underscore must be followed by a letter
$99Var   // invalid - must begin with a letter or underscore
Advertisement