Link to home
Start Free TrialLog in
Avatar of Richard Korts
Richard KortsFlag for United States of America

asked on

Path info

We have a live system & a test system on the same host. The test system is at www.xyz.com/test. The live system is at www.xyz.com.

Apache server.

How can I determine, from within an executing php program, which one I'm in?

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Frosty555
Frosty555
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richard Korts

ASKER

To Frosty555

Thanks, I kind of remember that from previously.

I found another way. I know the base file in both systems is index.php. So I did this:

$path = realpath("index.php");
$lp = strlen($path);
$type = "prod";
for ($j = $lp - 1; $j >0; $j--) {
      if (substr($path,$j,1) == "/") {
            if (substr($path, $j-4,4) == "test") {
                  $type = "test";
                  break;
            }
      }
}
echo $type;