Lesson 1 - PHP Flashcards
Basic structure of the code section
<?php
coding line;
coding line;
coding line;
?>
(each line needs to end with ;)
saving php pages
all pages which contain PHP code, must
be saved with a PHP extension.
* Eg dbaccess.php
where to save the pages
inside the www folder (or subfolder) of
the WAMP server.
* Eg C:\wamp64\www\samplesite
why is an echo used
to output text onto the web page
The syntax is:
echo “the text including any variables”;
(use single quotes)
to test your file
you must view it via localhost
e.g. http://localhost/phpsandbox/myfirst.php
what are variables
variables are named storage spaces where data is stored temporarily
manipulating variables
Values stored in variables can be manipulated mathematically,
brought together as text, displayed on screen or checked against
other values.
naming variables
must start with a $ (only contains letters/no. or underscores
assigning a value
Syntax is
$variablename = value;
e.g. $myage = 15;
storing values into variables
e.g. $myage = 15;