Verification: a143cc29221c9be0

Php check if index page

Содержание

Example 1.

The following code will evaluate to true because the main string $str contains the substring ‘This‘ in it. This will print “true”.

$str = 'This is Main String';

if (strpos($str, 'This') !== false) {

    echo 'true';

}

?>

Output: true

Example 2.

The following code will evaluate to false because the main string $str doesn’t contains the substring ‘Hello‘ in it. This will nothing print.

$str = 'This is Main String';

$substr = "Hello";

if (strpos($str, $substr) !== false) {

    echo 'true';

}

?>

Output: none

Example 3.

The following code will check if a String contains a substring at start. The following code will evaluate to true because the main string $str contains the substring ‘This‘ at start.

$str = 'This is Main String';

if (strpos($str, 'This') === 0 ) {

    echo 'true';

}

?>

Output: true