Hello , can please tell me any name of built in function that returns true/or false on with given variable and findable string .. like strstr or substr etc. but they return a output but i want boolean value on return..
Just typecast the result as a bool: echo (bool) stristr('mystring', 'str'); Code (markup): PS "Beginner PHP Expert" Dude, wtf...
strpos will return a boolean false for not found, or an integer indicating the position. if(strpos('...', $str) === false) Code (markup):
No. You must check for a boolean false using the strict-equality operator (===) in order to make it work with strpos. Unless you want it to miss it being the first word in the string.