GET Requests Using Links in PHP
In the real world, of course, users
of your site will not send GET
requests manually through the address bar.
For this, we will provide them with links
containing GET request parameters.
Users will click on the links
and automatically send GET requests.
Let's look at examples. When clicking
on the following link we will go to the page
index.php, sending GET parameters:
<a href="index.php?par1=1&par2=2">link</a>
The page itself in the link can be omitted,
and the address can simply start with the sign ?.
In this case, when clicking the link we will return
to the current page, but with GET parameters
in the address bar. Here is an example:
<a href="?par1=1&par2=2">link</a>
Make three links. Let the first one pass
the number 1, the second - the number 2,
the third - the number 3. Make it so that
when clicking on a link, its number is displayed on the screen.
Generate 10 links in a loop. Let
each link pass its own number. Make
it so that when clicking on a link, its number
is displayed on the screen.
Given an array:
$arr = ['a', 'b', 'c', 'd', 'e'];
Make it so that using a GET
request, any element of this array can be displayed.
To do this, use a foreach loop
to make a link for each element of the array.