<?php // 应用公共文件 function startsWith($haystack, $needle) { return strncmp($haystack, $needle, strlen($needle)) === 0; } function endsWith($haystack, $needle) { return $haystack != '' && $needle != '' && substr_compare($haystack, $needle, -strlen($needle)) === 0; }