Follow this lesson in Ullman Chapter 2. The scripts are located in the 02 directory.
View the page print_r.php described in Ullman pp. 26 ff.
Note the Ullman section on Predefined Variables on page 26.
Printing your $GLOBALS value is valuable for debugging.
The $ must come first.
Variable names can start with a letter or an underscore: _
Variable names cannot start with a number or other character.
Variable names are case-sensitive.
But you need not declare a variable before using it!
“under_score” vs. “camelHump” methods.
There is no “date” variable type in PHP.
Numerically indexed (indexed arrays)
Keyword-indexed (associative arrays)
See Ullman page 35 for two examples of arrays.
= the assignment operator
View the page variables.php described on pp. 38-39 of Ullman.
” ” – weak quotes
The purpose of weak quotes is to preserve empty spaces.
‘ ‘ – strong quotes (literal quotes)
The purpose of strong quotes is to allow you to pass literal strings. Variables etc. will NOT be interpreted.
See the page quotes.php described on pp 40-41 of Ullman.
Create your own demonstration page for these techniques:
- printing your GLOBALS array;
- creating and assigning variables;
- displaying variables; and
- demonstrating the effects of weak and strong quotes.
Be sure to link this page to your index.htm.
As a test to see if you’re reading these instructions, I’m going to check that you have substituted your name for Ullman’s! (Just kidding.)
Review Chapter 2 of Ullman.