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 slugify(text) | |
{ | |
var fromChar = [/ą/ig, /ę/ig, /ó/ig, /ś/ig, /ł/ig, /ż/ig, /ź/ig, /ć/ig, /ń/ig]; | |
var toChar = ['a', 'e', 'o', 's', 'l', 'z', 'z', 'c', 'n']; | |
for ( var i in fromChar ) | |
text = text.replace(fromChar[i], toChar[i]); | |
return text.toString().toLowerCase() | |
.replace(/\s+/g, '-') // Replace spaces with - | |
.replace(/[^\w\-]+/g, '') // Remove all non-word chars | |
.replace(/\-\-+/g, '-') // Replace multiple - with single - |
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
SZYMON NIKIEL 20:07:15 | |
JAROSŁAW KOCUR 20:39:32 | |
TOMASZ BARSZCZ 19:10:39 | |
KAMIL KLICH 20:39:01 | |
JAREK GONCZARENKO 17:32:25 | |
AGATA MATEJCZUK 18:52:36 | |
GRZEGORZ MENET 19:23:15 | |
KRYSTIAN KORZAŃSKI 19:17:57 | |
MARCIN MIKOŚ 18:14:11 | |
BARTOSZ MALAWSKI 18:12:31 |
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 add(int $a, int $b): int { | |
return $a + $b; | |
} | |
add(1, '2'); |
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 | |
declare(strict_types=1); // musi być w 1 linii | |
function add(int $a, int $b): int { | |
return $a + $b; | |
} | |
add(1, '2'); | |
// Catchable fatal error: Argument 2 passed to add() must be of the type integer, string given |
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 | |
// przed php 7 | |
uasort($array, function($a, $b){ | |
return ($a < $b) ? -1 : (($a > $b) ? 1 : 0); | |
}); | |
// po php 7 | |
uasort($array, function($a, $b){ | |
return $a <=> $b; | |
}); |
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 | |
try { | |
nonExistentFunction(); | |
} catch (\EngineException $e) { | |
var_dump($e); | |
} | |
object(EngineException)#1 (7) { | |
["message":protected]=> | |
string(32) "Call to undefined function nonExistantFunction()" |
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 | |
// call closures assigned to properties | |
($object->closureProperty)() | |
// chain static calls | |
class foo { static $bar = 'baz'; } | |
class baz { static $bat = 'Hello World'; } | |
baz::$bat = function () { echo "Hello World"; }; |
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 | |
// co zwróci podane wyrażenie ? | |
$obj->$properties['name']; | |
// w PHP 5.6 | |
$obj->{$properties['name']} | |
// w PHP 7 | |
{$obj->$properties}['name'] |
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 | |
// proste zastosowanie | |
$username = $user->getName() ?? 'nobody'; | |
// dobre do tablic bo nie trzeba sprawdzać isset | |
$width = $imageData['width'] ?? 100; | |
// bardziej złożony przykład | |
$config = $config ?? $this->config ?? static::$defaultConfig; |
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 | |
// do PHP 5.6 | |
use Framework\Component\ClassA; | |
use Framework\Component\ClassB as ClassC; | |
use Framework\Component\OtherComponent\ClassD; | |
// od PHP 7 | |
use Framework\Component\{ | |
ClassA, | |
ClassB as ClassC, |
OlderNewer