开发者

Creating If/Else based on URL of page

开发者 https://www.devze.com 2023-03-21 22:51 出处:网络
Basically what I\'m trying to do is create an if/else statement based on the URL of the current site im on. The if/else statement is going to echo a list based on an alphabetical range. So in other wo

Basically what I'm trying to do is create an if/else statement based on the URL of the current site im on. The if/else statement is going to echo a list based on an alphabetical range. So in other words, If the url starts with letters between (A-G) I want it to echo one thing, and if it starts with letters (H-Z) I want it to echo something else. Th开发者_C百科is script will be used on many websites. Thanks


<?php
    $uri = strtoupper(isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/CLI');
    if(ord($uri[1]) <= ord('G'))
        echo "Echo one thing";
    else
        echo "Echo something else";


look into $_SERVER['REQUEST_URI']

0

精彩评论

暂无评论...
验证码 换一张
取 消