9951 explained code solutions for 126 technologies


phpCheck if string contains specific substring


if ( strpos($str, 'test') !== false ) { echo 'it is'; }ctrl + c
strpos

this function will return position of found substring

$str

string variable to search in

'test'

substring to search for

!== false

use strict comparison, because of 0 == false issue

echo 'it is';

execute this code when string contains needed substring