我如何编写两个带字符串的函数,如果它以指定的字符/字符串开头或以它结尾,则返回?
例如:
$str = '|apples}';
echo startsWith($str, '|'); //Returns true
echo endsWith($str, '}'); //Returns true
Run Code Online (Sandbox Code Playgroud) 我正在尝试检查一个字符串是否以http.我怎么做这个检查?
$string1 = 'google.com';
$string2 = 'http://www.google.com';
Run Code Online (Sandbox Code Playgroud)