javascript - Get the url parameter or the part of the url after the question mark (?) of an included php file

789

I basically have this "info.php" file included in another php file which is "main_page.php". By clicking a link in the page, the link sends a url parameter to the "info.php" file through javascript by reloading the page, giving it a new url. The "info.php" file then, for instance, becomes "info.php?student=1" which is, again, to be clear, included inside the "main_page.php" file. I've researched for solutions but what I only found are those javascripts and php scripts that gets the current url in the address bar.

Is there a way to do this, getting the new url of an included php file? If there is, then please forgive me for my dumbness and irresponsibly inadequate researching. Thank you so much.

172

Answer

Solution:

This is what you are looking for.

$_SERVER['QUERY_STRING']

Here is the documentation

720

Answer

Solution:

You should be able to access your URL query variables through the global $_GET array.

$_GET['student']

If not, please edit your question with some actual code like to have a better idea of what you are trying to achieve.

People are also looking for solutions to the problem: php - Yii2: Change page without reloading the page

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.