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 Logger { //Örnek kullanım olarak Database veya Config gibi tek class dan yönetmek gibi olabilir | |
private static $instance = null; | |
public static function getInstance() //Sadece bir kere oluşturulmuş olan sınıfımızı çağırmak için kullanıyoruz. | |
{ | |
if(self::$instance === null){ //Eğer daha önce bu sınıf hiç oluşturulmadıysa bir kereliğine oluşturacak. | |
self::$instance = new static(); //new static() yerine new self() de kullanabilirdik ancak buradaki detayı aralarındaki farka araştırarak karar vermelisiniz. |
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 | |
abstract class Fruit { // Abstraction kullanılmıştır. | |
// Properties // Encapsulation kullanılmıştır | |
public $color; | |
//Magic Methods | |
function __construct($color) { //Oluşturucu: Sınıf ilk oluşturulduğunda tetiklenir. | |
$this->color = $color; | |
} |
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 | |
//https://www.phpliveregex.com/ //testin yapılması | |
//wiki baz alındı: https://en.wikipedia.org/wiki/Vehicle_registration_plates_of_Turkey | |
$GLOBALS['regexPlate1'] = "/\b\d{2}\W[A-Z]{1,3}\W\d{2,5}\b/"; // 99 X 99 ~ 99 XXX 99999 | |
$GLOBALS['regexPlate2'] = "/\b\d{2}[a-zA-Z]{1,3}\d{2,5}\b/"; // 99X99 ~ 99XXX99999 | |
/* | |
\b kelime sınırlama | |
\d sayı |
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 | |
/** | |
* If fileName have this characters \,/,:,*,?,",<,>,| return false but if not return true. | |
* @param $fileName | |
* @return string | |
*/ | |
function folderOrFileNameRegex($fileName){ | |
return !preg_match('/[\\\\,\/,:,*,?,",<,>,|]/', $fileName); | |
} |
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 | |
//Single Responsibility Principle | |
class Car | |
{ | |
private $name; | |
private $weight; | |
function __construct($name) | |
{ |
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 | |
//Open Closed Principle | |
abstract class Wing | |
{ | |
public abstract function flap(); | |
} | |
class Car extends Wing | |
{ |
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 | |
//Liskov Substitution Principle | |
interface Wing | |
{ | |
public function flap(); | |
/** | |
* Chicken class'ında tavuk uçamaz bu yüzden fly ayrı bir interface alınmıştır. | |
*/ |
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 | |
//Interface Segregation Principle | |
interface Wing | |
{ | |
public function flap(); | |
} | |
interface FlyingWing | |
{ |
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 | |
//Dependency Inversion Principle | |
class Car | |
{ | |
private $name; | |
private $weight; | |
function __construct($name) |
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 | |
$char = array("a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","="); | |
$charEncrypt = array("!1","!2","!3","!4","!5","!6","#0","#1","#3","#4","#5","#6","$1","$2","#3","$4","$5","$6","%1","%2","%3","%4","%5","%6","<1","<2","<3","<4","<5","<6","&1","&2","&3","&4","&5","&6","+1","+2","+3","+4","+5","+6","*1","*2","*3","*4","*5","*6","-1","-2","-3","-4","$9"); | |
$testData = 'test'; | |
echo $testData.'<br/>'; | |
//Encryption | |
$encryption = base64_encode($testData); //data base64 şifrelenir. |
OlderNewer