网址中的PHP正则表达式编号

Der*_*vin 2 php regex

我有一个博客,我想在MAIN页面上显示ADS或特殊文本,但不在任何其他带有URI的页面上显示/?paged=[number].我已经尝试过标准正则表达式,/^[0-9].$/但它无法匹配.

我不确定我做错了什么或怎么做这个

if (substr_count($_SERVER[REQUEST_URI], "/") > 0 AND
substr_count($_SERVER[REQUEST_URI], "/?paged=1") == 0 AND
substr_count($_SERVER[REQUEST_URI], "/?paged=2") == 0 AND
substr_count($_SERVER[REQUEST_URI], "/?paged=3") == 0 AND
substr_count($_SERVER[REQUEST_URI], "/?paged=4") == 0 AND
substr_count($_SERVER[REQUEST_URI], "/?paged=5") == 0) {
echo "display special text, banners, and other stuff";
}
Run Code Online (Sandbox Code Playgroud)

这就是我目前的做法,但我不想做成千上万的......

chr*_*her 7

你能不能只检查了存在paged的在GET阵?

if(!isset($_GET['paged'])) {
    // You know this is the main page.
}
Run Code Online (Sandbox Code Playgroud)