Full Stack LAMP - MEAN Developer, Python developer. Certified Azure Developer. Freelance programmer/consultant/trainer.

It checks if the given substring contains a given string. If the substring mentioned will be present in the string then it will return True otherwise it will return False.

<?php
 
if(str_contains("abc", "a")) { 
  echo 'Found';
}

str_contains("abc", "d"); // false
 

str_contains() function is case-sensitive. There is no case-insensitive variant of this function.

str_contains() function always returns a boolean value.

str_contains() function will return TRUE in case of checking for the substring ("") as empty.

<?php

str_contains('Foo', ''); // true
str_contains('', ''); // true

I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Most Voted
Newest Oldest
Inline Feedbacks
View all comments