1$myString = 'Hello Bob how are you?';
2if (strpos($myString, 'Bob') !== false) {
3 echo "My string contains Bob";
4}
1$string = 'The lazy fox jumped over the fence';
2
3if (str_contains($string, 'lazy')) {
4 echo "The string 'lazy' was found in the string\n";
5}
6
7
1$a = 'How are you?';
2
3if (strpos($a, 'are') !== false) {
4 echo 'true';
5}
6
1
2<?php
3$string = 'The lazy fox jumped over the fence';
4
5if (str_contains($string, 'lazy')) {
6 echo "The string 'lazy' was found in the string\n";
7}
8
9if (str_contains($string, 'Lazy')) {
10 echo 'The string "Lazy" was found in the string';
11} else {
12 echo '"Lazy" was not found because the case does not match';
13}
14
15?>
16
17