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
str_replace() fonksiyonu ile ister string içinde ister dizi içinde istediğimiz kelimeleri veya karakterleri değiştirebiliriz. En baştan şunu söyleyeyim, str_replace() fonksiyonu büyük küçük harflere duyarlıdır (case-sensitive), büyük küçük harflere duyarsız (case-insensitive) fonksiyon için str_ireplace() fonksiyonunu kullanmalısınız. 2 fonksiyonun da kullanımları aynıdır. 4 parametre alabilir ancak genel olarak 3 parametre ile kullanılır.
Syntax
str_replace(find,replace,string,count)
str_ireplace(find,replace,string,count)
find: Zorunludur. Stringde ya da dizide değişecek değer girilmeli.
replace: Zorunludur. String ya da dizideki değerin ne ile değiştirileceği girilmeli.
string: Zorunludur. Üzerinde işlem yapılacak string veya dizi girilmeli.
count: İsteğe bağlıdır. Kaç kere değiştirme işlemi uygulandığını döndürür.
Not: str_replace() fonksiyonu orijinal stringi veya diziyi bozmaz.
Örnek 1)
<?php
$metin = "Burada 5 yazıyor";
$bul = "5";
$degistir = "6";
echo $metin;
// Çıktı: Burada 5 yazıyor
$metin = str_replace($bul, $degistir, $metin);
echo $metin;
// Çıktı: Burada 6 yazıyor
?>
Örnek 2)
<?php
$metin = "Burada 5 yazıyor";
$bul = "5";
$degistir = "6";
echo $metin;
// Çıktı: Burada 5 yazıyor
$metin = str_replace($bul, $degistir, $metin, $sayi);
echo $metin. "<br>";
echo "Değiştirme sayısı: ". $sayi;
// Çıktı: Burada 6 yazıyor
// Değiştirme sayısı: 1
?>
Örnek 3)
<?php
$metin = "Burada 5 ve 6 yazıyor";
$bul = array("5","6");
$degistir = array("10","11");
echo $metin;
// Çıktı: Burada 5 ve 6 yazıyor
$metin = str_replace($bul, $degistir, $metin);
echo $metin. "<br>";
// Çıktı: Burada 10 ve 11 yazıyor
?>
Örnek 4)
<?php
$metin = "Burada 5 ve 6 yazıyor";
$bul = array("5","6");
$degistir = array("10","11");
echo $metin;
// Çıktı: Burada 5 ve 6 yazıyor
$metin = str_replace($bul, $degistir, $metin, $sayi);
echo $metin. "<br>";
echo "Değiştirme sayısı: ". $sayi;
// Çıktı: Burada 10 ve 11 yazıyor
// Değiştirme sayısı: 2
?>
Örnek 5)
<?php
$dizi = array("mavi","kırmızı","yeşil","sarı");
$bul = array("mavi","kırmızı");
$degistir = array("lacivert","gri");
print_r($dizi);
// Çıktı: Array ( [0] => mavi [1] => kırmızı [2] => yeşil [3] => sarı )
$dizi = str_replace($bul,$degistir,$dizi,$sayi);
print_r($dizi);
echo "Değiştirme sayısı: ". $sayi;
// Çıktı: Array ( [0] => lacivert [1] => gri [2] => yeşil [3] => sarı )
// Değiştirme sayısı: 2
?>
YORUMLAR
<?php
$metin = "türkçe TÜRKÇE boşnakça BOŞNAKÇA";
$bul = array("türkçe","TÜRKÇE","boşnakça","BOŞNAKÇA");
$degistir = array("<a href='http://www.turkce.com'>türkçe</a>","<a href='http://www.turkce.com'>TÜRKÇE</a>",
"<a href='http://www.bosnakca.com'>boşnakça</a>","<a href='http://www.bosnakca.com'>BOŞNAKÇA</a>");
echo $metin;
$metin = str_ireplace($bul, $degistir, $metin);
echo $metin;
?>