Jump to content

Recommended Posts

Hey guys,

 

Am needing some help on an idea i brought up... i have scripts and pages that only respond in certain "Cities" on my site... by doing this is put the first letter of each city infront of the script names so there are all like Lhome.php Lgym.php etc

 

Now what i want to try and do is something where by using $_SERVER['PHP_SELF']

 

I want to use a wild card to do if $_SERVER['PHP_SELF'] begins with L wildcard then ok, else header location "phpscript.php"

 

is this possible, if so how is it done  ???

Link to comment
https://forums.phpfreaks.com/topic/75106-solved-wildcard-with-php-self/
Share on other sites

You don't even need the function:

 

<?php
$str = $_SERVER['PHP_SELF'];
echo $str[1]; //using 1 rather than 0, since 0 is the forward slash
?>

 

 

I tried this:

 

 

php script named "London.php"

$str = $_SERVER['PHP_SELF'];
If ($str{0} == 'L'){
Echo 'test1';
}
Else{
Echo ' test2';
}

 

yet it echo's test2 and not test 1 :S

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.