Web Programming - Week 5 Flashcards
What are dynamic web pages
Web pages that are not prebuilt
Advantages and Disadvantages of dynamic web pages
Advantages: Dynamic and Interactive
Disadvantages: Slower than Static web pages
Dynamic web page languages
PHP, Python, ASP
PHP Basics
PHP Files have extension .php
A PHP script starts with < ?php ends with ? >
PHP can be embedded in HTML
PHP statements are terminated by a semicolon
Comments in PHP
# or // - Single line /* */ - Multi line
PHP Variable Syntax
$variable_name = value
PHP Strings
Enclosed in single or double quotes
Concatenated with .
Interpolated variables
Double quotes interpolates variables in a string, single quotes do not
Output in PHP
Browser only shows front end, PHP script is replaced by its output in HTML
Print in PHP
print() - prints 1 value
print_r() - prints structured values
Echo in PHP
Not a function so no brackets needed
Like print function
foreach syntax
foreach ($myArray as $value){ //statements ; }
DataType check function
is_datatype($v)
Number Array Syntax
$array_name = array(“Value1”, “Value2”, etc…) ;
OR 0 => “Value1” etc…
Associative Array Syntax
$array_name = array(“Name1”=Value1, “Name2”=Value2, etc…) ;