This file contains 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 | |
function __autoload($class) { | |
require $class . '.php'; | |
} |
This file contains 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 | |
function to_camel_case($str, $capitalise_first_char = false) { | |
if($capitalise_first_char) { | |
$str[0] = strtoupper($str[0]); | |
} | |
$func = create_function('$c', 'return strtoupper($c[1]);'); | |
return preg_replace_callback('/_([a-z])/', $func, $str); | |
} |
This file contains 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 | |
// once you add the magical setter and getter | |
// you can can access any private fields as usual | |
// but you can also develop custom setter and getter if you want | |
$user = new MagicUser(); | |
$user->username = "test"; | |
$user->password = "pass"; | |
echo $user->username; // will print Test not test. |
This file contains 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 CustomerController extends Controller{ | |
public function __construct() | |
{ | |
if(!$this->session->get('user_id')){ | |
$this->redirect("/login"); | |
} | |
} | |
} |
This file contains 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 | |
/** | |
* Group cart items by category, and calculate the total of each category ;) | |
**/ | |
$cart = [ | |
[ "name" => "product A", "price" => 15, "qty" => 5, "category" => "category 1"], | |
[ "name" => "product B", "price" => 20, "qty" => 4, "category" => "category 2"], | |
[ "name" => "product C", "price" => 30, "qty" => 2, "category" => "category 1"], |
This file contains 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 | |
/** | |
* Go from $scores to $result without using any loops! | |
*/ | |
$scores = [ | |
["player_id" => 3, "name" => "player #1", "score" => 150, "bonus" => 200], | |
["player_id" => 4, "name" => "player #2", "score" => 120, "bonus" => 100], | |
]; |
This file contains 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 | |
$user = [ | |
"workHours" => [ | |
["from" => "08:00:00", "to" => "16:00:00"], | |
[], | |
["from" => "08:00:00", "to" => "16:00:00"], | |
[], | |
["from" => "08:00:00", "to" => "16:00:00"], | |
[], |
This file contains 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 | |
require_once 'vendor/autoload.php'; | |
const FREE_TIME = 1; | |
$user = [ | |
"workHours" => [ | |
["from" => "08:00:00", "to" => "16:00:00"], | |
[], |
This file contains 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 | |
use \Achse\Math\Interval\Utils\StringParser\IntegerIntervalStringParser as Parser; | |
require_once 'vendor/autoload.php'; | |
const FREE_TIME = "01:00:00"; | |
$user = [ | |
"workHours" => [ |
This file contains 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 B | |
{ | |
} | |
class A | |
{ | |
private $b; |
OlderNewer