A PHP Error was encountered

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

A PHP Error was encountered

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

A PHP Error was encountered

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

A PHP Error was encountered

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

A PHP Error was encountered

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

A PHP Error was encountered

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

A PHP Error was encountered

Severity: 8192

Message: setcookie(): Passing null to parameter #7 ($httponly) of type bool is deprecated

Filename: core/Input.php

Line Number: 410

strpos() Fonksiyonu Kullanımı
Öneri ve Hata Raporu



Günün Sözü Sevemez kimse seni benim sevdiğim kadar

kategori PHP
oylama 2.9/5 yorum 0 yorum yazar Hakan Taşan tarih 20 Haziran 2015

strpos() fonksiyonu bir stringin başka bir string içerisinde bulunduğu ilk konumu döndürür. Örneğin; "sen seni bil sen seni" stringi içerisinde "sen" stringinin bulunduğu ilk konum değerini döndürür. Büyük küçük harflere duyarlıdır (case-sensitive). Stringin ilk karakteri 0'dan başlar (array gibi). Eğer aranan stringi bulamazsa FALSE değeri döndürür. Şimdi strpos() fonksiyonunun kullanımını ve buna benzer diğer fonksiyonların kullanımını karşılaştıralım ve örneklendirelim.

Syntax

strpos(string,find,start)

 

string: Zorunludur. İçerisinde arama yapılacak stringi ifade eder.

find: Zorunludur. Aranacak stringi ifade eder.

start: İsteğe bağlıdır. Stringin hangi konumundan itibaren arama yapılacağını ifade eder.

strpos() - Bir stringin başka bir string içerisinde bulunduğu ilk konumu döndürür. Büyük küçük harflere duyarlıdır (case-sensitive).

stripos() - Bir stringin başka bir string içerisinde bulunduğu ilk konumu döndürür. Büyük küçük harflere duyarsızdır (case-insensitive).

strrpos() - Bir stringin başka bir string içerisinde bulunduğu son konumu döndürür. Büyük küçük harflere duyarlıdır (case-sensitive).

strripos() - Bir stringin başka bir string içerisinde bulunduğu son konumu döndürür. Büyük küçük harflere duyarsızdır (case-insensitive).

Örnek

<?php
    $metin = "sen seni bil sen seni";
    
    echo strpos($metin,"seni");    // Çıktı: 4
?>

 

Karşılaştırmalı Örnekler

<?php
    $metin = "sen seni bil sen seni";

    // strpos() Büyük küçük harfe duyarlı
    echo strpos($metin,"SEni");    // Çıktı: FALSE

    // stripos() Büyük küçük harfe duyarsız
    echo stripos($metin,"SEni");    // Çıktı: 4

    // strrpos() Büyük küçük harfe duyarlı
    echo strrpos($metin,"SEni");    // Çıktı: FALSE

    // strripos() Büyük küçük harfe duyarsız
    echo strripos($metin,"SEni");    // Çıktı: 17
?>

 

paylaş Paylaş
oylama yap Oyla

makale yorumları YORUMLAR

Bu makale için yorum yazılmamış