Paul Paul - 1 month ago 6
PHP Question

How to obtain part of the url with php

I am coming up with a way to display user profiles. Right now I am able to insert the user_id into the url when going to a user's profile, but I am unsure of how to get the user_id from the url.

So at the end of the url I have this:

profile?user=41

I just want to be able to get the 41 (please note this number will change per profile) and then set it to a variable.

How would I do this?

Answer
<?php
    echo $_GET['user'];
?>

all the parameters of the url are stored in the $_GET variable...