0

I'm sorry if is a repeated question, but i having trouble with PHP. I'm working with the code of another programer, and he is using php. In one of the pages que get the information from the url, but no via post nor get, but by attaching it to the url and putting / between them, like this: www.example.com/memorial/31/john

the he uses 31 and john as data. I have no memorial directory, neither a file called memorial.

Is there a way to do this in PHP without a framework, he doesn't seem to be using any libraries either.

1
  • 1
    You should be able to find a .htaccess file in the root of the project. This is rewriting that url into get variables. Commented Feb 19, 2012 at 22:23

2 Answers 2

2

The most likely explanation is that he is using an URL rewrite engine, such as Apache's mod_rewrite. This will be doing something like turning the directory parts into GET variables.

Sign up to request clarification or add additional context in comments.

Comments

0

You can find that information in the global $_SERVER variable: $_SERVER['REQUEST_URI']. As @Oli mentioned, this is probably through a rewrite engine.

For example if you went to the URL you mentioned (www.example.com/memorial/31/john):

$uriPieces = explode('/',$_SERVER['REQUEST_URI'],'/');
// this gets rid of all of the cases of double-slashes as well as the initial 
// and trailing. This is optional, but I will generally prefer it.
$uriPieces = array_filter($uriPieces);
print_r($uriPieces);

Outputs

Array
(
    [0] => memorial
    [1] => 34
    [2] => john
)

If you search your project for REQUEST_URI, you will find where the variables are being set.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.