我想检查路径是否包含字符串,
比如,如果路径包含plugins
则返回false
,如果路径包含themes
则返回true
。
D:\wamp\www\wp-content/plugins/someplugin/index.phtml // return false
D:\wamp\www\wp-content/themes/index.php // return true
我想检查路径是否包含字符串,
比如,如果路径包含plugins
则返回false
,如果路径包含themes
则返回true
。
D:\wamp\www\wp-content/plugins/someplugin/index.phtml // return false
D:\wamp\www\wp-content/themes/index.php // return true
只是因为@Dave Chen问:
So what would wp-plugins or wp-themes trigger?
然后,设置完全匹配:
$themes = "/themes/";
$file01 = "D:\wamp\www\wp-content/themes/index.php";
$file02 = "D:\wamp\www\wp-content/wp-themes/index.php";
$is_theme = stripos($file01, $themes ); // returns true
$is_theme = stripos($file02, $themes ); // returns false
我希望这就足够了。
<?php
$pos1 = stripos('D:\wamp\www\wp-content/theme/someplugin/index.phtml', 'theme');
if ($pos1 === false) {
echo "Not a theme";
}
else
{
echo "It's a theme !";
}
?>
输出:
这是一个主题!