PHP Version
4.0.6+
$str = 'こんにちは。ようこそ!'; // "Hello. Welcome!"
$substring = 'ようこそ';           // "Welcome"

$pos = mb_strpos($str, $substring);

if ($pos !== false) {
    echo "Found at position: $pos";
} else {
    echo 'Substring not found.';
}

// Output: Found at position: 6

/*
 * Note:
 * In PHP, string indexes start at 0.
 * The index of the first character is 0, the second character is 1, and so on.
 */
$str = 'こんにちは。ようこそ!'; // "Hello. Welcome!"
$substring = 'ようこそ';           // "Welcome"

$pos = strpos($str, $substring);

if ($pos !== false) {
    echo "Found at position: $pos";
} else {
    echo 'Substring not found.';
}

// Output: Found at position: 18 <= Unexpected result
mb_strpos(
    string $haystack,
    string $needle,
    int $offset = 0,
    ?string $encoding = null
): int|false
$str = 'Hello, World!';
$substring = 'world';

$pos = mb_strpos($str, $substring);

if ($pos === false) {
    echo "Cannot find 'world!' because the case does not match.";
} else {
    echo "'world!' is included in the string.";
}

// Output: Cannot find 'world!' because the case does not match.
$newstring = 'abcdef ghijk';
$pos = mb_strpos($newstring, 'a');

var_dump($pos); // int(0)
$str = 'Hello, World!';
$substring = '';

$pos = mb_strpos($str, $substring); // Warning: mb_strpos(): Empty delimiter in
$str = 'Hello, World!';
$substring = 'Hello';

$pos = mb_strpos($str, $substring);

var_dump($pos); // int(0)

if ($pos === false) {
    echo "The string 'Hello' was not found.";
} else {
    echo "The string 'Hello' is included in the text.";
}

// Output: The string 'Hello' is included in the text.