This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mathematical Operations | |
* Addition, +, 5+2 = 7 | |
* Subtraction, -, 5-2 = 3 | |
* Multiplication, *, 5*2 = 10 | |
* Division, /, 5/2 = 2.5 | |
* Modulus, %, 5%2 = 1 | |
* | |
* Short Hand Operations |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Mathematical Comparison Operators | |
* x > y, is x greater than y? | |
* x >= y, is x greater than OR equal to y? | |
* x < y, is x less than y? | |
* x <= y, is x less than OR equal to y? | |
* | |
* Logical Comparison Operators | |
* x == y, does x have the same value as y? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* for loops | |
* where to start; when to continue; how to step through | |
**/ | |
for($i = 0; $i < 10; $i++){ | |
// start at i = 0 and continue until i is >= 10 | |
echo $i; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Programming in PHP | |
* Week 3 - Day 5 | |
* Playing with Strings | |
**/ | |
/** | |
* length of a string! | |
**/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Playing with Arrays | |
* List of functions: http://us2.php.net/manual/en/ref.array.php | |
**/ | |
// Creating an array | |
$array = array('value1', 2, 'value3', 4.5); | |
// Remember an array starts at position 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Creating our own functions | |
**/ | |
// Our First Function | |
function firstFunction(){ | |
return 'Hello buddy, how is it going?'; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Recursive Functions | |
**/ | |
/** Solving a Factorial **/ | |
// Non Recursively | |
function factorial_NoRecursion($x){ | |
$y = 1; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Using GET | |
**/ | |
// the variable $_GET is an array | |
print_r($_GET); | |
// the URL is get.php?page=index | |
echo $_GET['page']; // index |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Using POST | |
**/ | |
// see if any post request has been made | |
if(count($_POST) > 0){ | |
print_r($_POST); | |
} |
OlderNewer