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 slug($str, $cat=false) { | |
$ene = ($cat === true) ? 'ny' : 'n'; | |
$str = (function_exists('mb_strtolower')) ? mb_strtolower($str, 'UTF-8') : strtolower($str); | |
$str = preg_replace('(à|á|â|ã|ä|å)', 'a', $str); | |
$str = preg_replace('(è|é|ê|ë)', 'e', $str); | |
$str = preg_replace('(ì|í|î|ï)', 'i', $str); | |
$str = preg_replace('(ò|ó|ô|õ|ö|ø|ō)', 'o', $str); | |
$str = preg_replace('(ù|ú|û|ü|ū)', 'u', $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
function slug($title, $separator = '-', $removeUnsupported = true) | |
{ | |
$charsArray = array( | |
'a' => array( | |
'à', 'á', 'ả', 'ã', 'ạ', 'ă', 'ắ', 'ằ', 'ẳ', 'ẵ', | |
'ặ', 'â', 'ấ', 'ầ', 'ẩ', 'ẫ', 'ậ', 'ä', 'ā', 'ą', | |
'å', 'α', 'ά', 'ἀ', 'ἁ', 'ἂ', 'ἃ', 'ἄ', 'ἅ', 'ἆ', | |
'ἇ', 'ᾀ', 'ᾁ', 'ᾂ', 'ᾃ', 'ᾄ', 'ᾅ', 'ᾆ', 'ᾇ', 'ὰ', | |
'ά', 'ᾰ', 'ᾱ', 'ᾲ', 'ᾳ', 'ᾴ', 'ᾶ', 'ᾷ', 'а', 'أ'), | |
'b' => array('б', 'β', 'Ъ', 'Ь', 'ب'), |
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 | |
// GUID v4 | |
public function guid() { | |
return sprintf( | |
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
// 32 bits for "time_low" | |
mt_rand(0, 0xffff), mt_rand(0, 0xffff), | |
// 16 bits for "time_mid" | |
mt_rand(0, 0xffff), | |
// 16 bits for "time_hi_and_version", |
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 | |
$app->get('', | |
function ( ) { | |
echo 'Hello!'; | |
} | |
); | |
$app->get('user/{id}/profile', | |
function ( $id ) { |
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 | |
// development | |
// testing | |
$environment = 'production'; | |
//------------------------------------------- | |
$config = [ |
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 | |
$access_key = "iam-user-access-key"; //Access Key | |
$secret_key = "iam-user-secret-key"; //Secret Key | |
$my_bucket = "mybucket"; //bucket name | |
$region = "us-east-1"; //bucket region | |
$success_redirect = 'http://'. $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; //URL to which the client is redirected upon success (currently self) | |
$allowd_file_size = "1048579"; //1 MB allowed Size | |
//dates |
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 generate_uuid(){ | |
$charid = md5(uniqid(rand(), true)); | |
$uuid = substr($charid, 0, 8) . "-" | |
.substr($charid, 8, 4) . "-" | |
.substr($charid,12, 4) . "-" | |
.substr($charid,16, 4) . "-" | |
.substr($charid,20,12); | |
return $uuid; |
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 generate_uuid() { | |
return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', | |
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), | |
mt_rand( 0, 0xffff ), | |
mt_rand( 0, 0x0fff ) | 0x4000, | |
mt_rand( 0, 0x3fff ) | 0x8000, | |
mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) | |
); |
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 Person { | |
private $name; | |
private $age; | |
private $id; | |
function __construct( $name, $age ) { | |
$this->name = $name; | |
$this->age = $age; |
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 Connection | |
{ | |
protected $link; | |
private $dsn, $username, $password; | |
public function __construct($dsn, $username, $password) | |
{ | |
$this->dsn = $dsn; | |
$this->username = $username; |