
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
The name of a variable always starts with a $
The character next to $ can NEVER be numeric
The characters: _, Ç e ç are allowed
Reserved characters, of course, can not be used
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
?>
| CHARACTERIZATION OF VARIABLES | ||
| SYMBOL | NAME | USE |
| $ | DOLLAR SIGN | CHARACTER that initiates the name of any variable. |
| BASIC RULES | ||
| The name of a variable always starts with a $. | ||
| The character next to $ can NEVER be numeric. | ||
| The characters: _, Ç e ç are allowed. | ||
| Reserved characters, of course, can not be used. | ||
| VALID EXAMPLES | ||
| REPRESENTATION | ATTENTION | |
| $VAL0001 | UPPERCASE and lowercase characters are treated differently! In this case, they determine different variables. |
|
| $val0001 | ||
| $Val0001 | ||
| $xyz | OK | |
| $str0x0 | OK | |
| $carÇ | Ç e ç are allowed. | |
| $_alo | _ is allowed. | |
| AGAINST EXAMPLE | ||
| REPRESENTATION | ATTENTION | |
| $1axp | The next character to $ is numerical! | |
| ed48 | ||
EXERCISE
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SOME VALID INTERNAL
VARIABLE EXAMPLES
- - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$_SERVER['REMOTE_ADDR']
// GETS THE REMOTE ADDRES, (IP)
$_SERVER['HTTP_USER_AGENT']
// GETS THE USER AGENT, (BROWSER)
$_SERVER['HTTP_ACCEPT_LANGUAGE']
// GETS THE ACEPTED LANGUAGE
/* - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you run this exercise as is,
you will receive a Parse error,
due to a syntax error
- - - - - - - - - - - - - - - - - - - - - - - - - - - */
?>
EXERCISE
<?php
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
SOME VALID USER-DEFINED
VARIABLE NAMES EXAMPLES
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
$xyz
$str0
$carÇ
$_alo
$rquo
$str01
$str02
$nbr01
$nbr02
$avB0a
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you run this exercise as is,
you will receive a Parse error
because for the VARIABLES
no value has been assigned
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
?>