4851 explained code solutions for 97 technologies

phpCheck if string contains specific substring

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

this function will return position of found substring


string variable to search in


substring to search for

!== false

use strict comparison, because of 0 == false issue

echo 'it is';

execute this code when string contains needed substring