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
Bu makalede PHP'nin devasa kütüphanesinden bize sunduğu metin işlemlerini gerçekleştireceğimiz strtoupper(), strtolower(), lcfirst(), ucfirst() ve ucwords() fonksiyonlarını inceleyeceğiz. 5 fonksiyonun da ortak özelliği ya büyük harfi küçüğe ya da küçük harfi büyüğe dönüştürür. Şimdi hepsini sırasıyla örneklerle inceleyelim.
1) strtoupper()
Bütün karakterleri büyük harfe dönüştürür.
Syntax
strtoupper(string)
Örnek Kod
<?php
echo strtoupper("Lorem ipsum dolor sit amet");
// Çıktı: LOREM IPSUM DOLOR SIT AMET
?>
2) strtolower()
Bütün karakterleri küçük harfe dönüştürür.
Syntax
strtolower(string)
Örnek Kod
<?php
echo strtolower("Lorem ipsum DOLOR sit amet");
// Çıktı: lorem ipsum dolor sit amet
?>
3) lcfirst()
Metnin ilk kelimesinin baş harfini küçük harfe dönüştürür.
Syntax
lcfirst(string)
Örnek Kod
<?php
echo lcfirst("Lorem ipsum DOLOR sit amet");
// Çıktı: lorem ipsum DOLOR sit amet
?>
4) ucfirst()
Metnin ilk kelimesinin baş harfini büyük harfe dönüştürür.
Syntax
ucfirst(string)
Örnek Kod
<?php
echo ucfirst("lorem ipsum DOLOR sit amet");
// Çıktı: Lorem ipsum DOLOR sit amet
?>
5) ucwords()
Metindeki her kelimenin baş harfini büyük harfe dönüştürür.
Syntax
ucwords(string)
Örnek Kod
<?php
echo ucwords("lorem ipsum DOLOR sit amet");
// Çıktı: Lorem Ipsum DOLOR Sit Amet
?>
Not: Türkçe harfleri büyük harfe veya küçük harfe çevirme işlemi hatalı olacaktır. Bu hatayı gidermek için bu karakterleri orijinal karakterlerle değiştirmek gerekir. Bu iş için hazırladığım 2 fonksiyonu size veriyorum.
<?php
function kucukten_buyuge($metin){
$bul = array('ı','i','ğ','ü','ş','ö','ç');
$degistir = array('I','İ','Ğ','Ü','Ş','Ö','Ç');
$metin = str_replace($bul,$degistir,$metin);
return $metin;
}
function buyukten_kucuge($metin){
$bul = array('I','İ','Ğ','Ü','Ş','Ö','Ç');
$degistir = array('ı','i','ğ','ü','ş','ö','ç');
$metin = str_replace($bul,$degistir,$metin);
return $metin;
}
?>
YORUMLAR
<input type="text" id="isim" onblur="ilkHarfBuyuk()">
<script type="text/javascript">
function ilkHarfBuyuk()
{
var str = document.getElementById("isim");
str.value = str.value.replace("I","ı").toLowerCase().replace(/(^|\\s)([a-zöçşğüı])/g, function(letter){
return letter.replace("i","İ").toUpperCase();
});
}
</script>