在PHP中,您可以使用strpos()函数来获取字符串中子字符串首次出现的位置。下面是一个示例:
$string = "Hello World";$substring = "World";$position = strpos($string, $substring);if ($position === false) {echo "Substring not found";} else {echo "Substring found at position " . $position;}这将输出:
Substring found at position 6请注意,strpos()函数区分大小写。如果要进行不区分大小写的搜索,可以使用stripos()函数。

