June 2005
Intermediate
720 pages
20h 6m
English
The first—arguably most important—variable type I’ll go into is strings. A string is merely a quoted chunk of letters, numbers, spaces, punctuation, and so forth. These are all strings:
'Tobias'
"In watermelon sugar"
'1,000'
'February 3, 2005'
To make a string variable, assign a string value to a valid variable name:
$first_name = 'Tobias'; $today = 'February 3, 2005';
To print out the value of a string, use either echo() or print():
echo $first_name;
To print the value of string within a context, use double quotation marks:
echo "Hello, $first_name";
In a way, you’ve already worked with strings once—when using the predefined variables in the preceding section.
1. | Create a new HTML document in your text editor, ... |
Read now
Unlock full access