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
Car and Garage Classes | |
IDEA: | |
A Garage of size n can store up to n Cars | |
A Garage is treated like a stack, where you can push and pop Cars "in" and "out" of your Garage | |
A Car is treated as an individual that gets stored inside the Garage | |
The Garage class: | |
Must be constructed with a name and a size. | |
The size is the amount of Cars the Garage can hold. |
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 | |
include 'Vehicle.php'; | |
class Car implements Vehicle { | |
private $seats; | |
private $type; | |
public function __construct($seats, $type){ | |
$this->seats = $seats; | |
$this->type = $type; |
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 | |
class FirstClass { | |
public $public; | |
protected $protected; | |
private $private; | |
public function __construct($public, $protected, $private){ | |
$this->public = $public; | |
$this->protected = $protected; |
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); | |
} |
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 | |
/** | |
* 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 | |
/** | |
* 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 | |
/** | |
* 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 | |
/** | |
* Programming in PHP | |
* Week 3 - Day 5 | |
* Playing with Strings | |
**/ | |
/** | |
* length of a string! | |
**/ |
NewerOlder