Severity: 8192
Message: Return type of CI_Session_files_driver::open($save_path, $name) should either be compatible with SessionHandlerInterface::open(string $path, string $name): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 113
Severity: 8192
Message: Return type of CI_Session_files_driver::close() should either be compatible with SessionHandlerInterface::close(): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 280
Severity: 8192
Message: Return type of CI_Session_files_driver::read($session_id) should either be compatible with SessionHandlerInterface::read(string $id): string|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 145
Severity: 8192
Message: Return type of CI_Session_files_driver::write($session_id, $session_data) should either be compatible with SessionHandlerInterface::write(string $id, string $data): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 223
Severity: 8192
Message: Return type of CI_Session_files_driver::destroy($session_id) should either be compatible with SessionHandlerInterface::destroy(string $id): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 303
Severity: 8192
Message: Return type of CI_Session_files_driver::gc($maxlifetime) should either be compatible with SessionHandlerInterface::gc(int $max_lifetime): int|false, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Filename: drivers/Session_files_driver.php
Line Number: 344
Severity: 8192
Message: setcookie(): Passing null to parameter #7 ($httponly) of type bool is deprecated
Filename: core/Input.php
Line Number: 410
Bildiğiniz gibi date() fonksiyonu ile tarihleri ve saatleri öğrenebiliyorduk ancak günler ve aylar maalesef İngilizce oluyordu. İngilizceden Türkçeye çevirmenin bildiğim 2 yolunu anlatacağım. 1. yol PHP'nin setlocale() fonksiyonunu kullanarak, 2. yol ise str_replace() fonksiyonunu kullanarak basit bir array işlemiyle yapabiliriz.
1. Yol: setlocale() Fonksiyonu
setlocale() fonksiyonu yereli ayarlar. Örneğin; yerel para birimi, karakter dönüşümleri, ondalık ayraçlar, tarih ve saat gibi. 2 parametre alır. 1. parametre hangi özelliğin yerelleştirileceğini, 2. parametre ise hangi dile dönüştürüleceğini belirtir.
setlocale(LC_TIME,"Turkish"); // LC_TIME tarihin, Turkish ise tarihin Türkçeye dönüştürüleceğini gösterir
Örnek
<?php
setlocale(LC_TIME,"Turkish");
echo strftime("%d %B %A %Y");
// Çıktı: 23 Haziran Salı 2015
?>
2. Yol: str_replace() Fonksiyonu
str_replace() fonksiyonu ile string içindeki ya da dizi içindeki istediğimiz değerleri değiştirebiliyoruz. Öncelikle İngilizce ve Türkçe olarak ay ve gün isimlerini ayrı ayrı dizilere atayıp daha sonra da bu fonksiyonu kullanarak dönüşüm işlemini yapacağız.
Örnek
<?php
date_default_timezone_set('Europe/Istanbul');
$tarih = date("d F l");
echo $tarih;
// Çıktı: 23 June Tuesday
$ing_aylar = array("January","February","March","May","April","June","July","August","September","October","November","December");
$tr_aylar = array("Ocak","Şubat","Mart","Nisan","Mayıs","Haziran","Temmuz","Ağustos","Eylül","Ekim","Kasım","Aralık");
$ing_gunler = array("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday");
$tr_gunler = array("Pazartesi","Salı","Çarşamba","Perşembe","Cuma","Cumartesi","Pazar");
$tarih = str_replace($ing_aylar,$tr_aylar,$tarih);
$tarih = str_replace($ing_gunler,$tr_gunler,$tarih);
echo $tarih;
// Çıktı: 23 Haziran Salı
?>
YORUMLAR