HTML – Basic Tags
Headers:
This is a big header.
This is a smaller header.
This is the smallest header
Paragraph: This is a paragraph
Link: This is a link
Image:
Unordered (bulleted) list:
- This is a list item .
- And another
Ordered (numbered) list:
- This is a list item .
- And another
Table:
Header cell |
Another header cell |
Regular cell |
Another regular cell |
HTML – Forms
Form:
PHP – Forms
$x=$_POST[“name”];
(where “name” matches the input name in your html file.)
===============================================
PHP – Basics
Variables: $x=5;
$y=33;
$total=9999;
Printing:
echo “The total is $total”;
print “x is equal to $x”;
Arithmetic Operators: Examples:
+ (plus) $x =5+$y;
- (minus) $total = $y-100;
* (times) $x_squared = $x*$x;
/ (divide) $half_total = $total/2;
PHP – Forms
$x=$_POST[“name”];
(where “name” matches the input name in your html file.)
-----------------------------------------------------------
PHP
Variables:
$x=5;
$word="hello";
Printing:
echo "This is a sentence";
print "The value is $x";
Comparison Operators:
== (equals)
!= (not equals)
> (greater than)
< (less than)
>= (greater than or equal to)
<= (less than or equal to)
Conditional statements:
if($x > 5) {
print "$x is greater than 5";
}
if($word == "hello") {
print "The word is hello";
}
else {
print "The word is not hello";
}
For loops:
for($i=starting number; $i<=ending number; $i++) {
//Everything between these braces is repeated
}
//start at 0; end at 30; add 1 to $i each time
for($i=0; $i<=30; $i++) {
echo "i is currently $i";
}
//start at 1; end at 19; add 5 to $i each time
for($i=1; $i<20; $i=$i+5) {
echo "i is currently $i";
}
Declaring Functions:
function subtract($x, $y) {
$value = $x-$y;
return $value;
}
function print_hello() {
echo "Hello World";
}
Using Functions:
$result=$subtract(10,5);
echo "$result
";
print_hello();