How can you pass variables using GET in PHP?
To pass variables using GET in PHP, you can append the variables to the URL as key-value pairs. This can be done by adding a question mark (?) after the URL followed by the variable name, an equal sign (=), and the variable value. Multiple variables can be passed by separating them with an ampersand (&). Example: URL: www.example.com/page.php?var1=value1&var2=value2 PHP Code:
$var1 = $_GET['var1'];
$var2 = $_GET['var2'];
echo "Variable 1: " . $var1 . "<br>";
echo "Variable 2: " . $var2;
Related Questions
- What program or service can be used to send a request to another host for setting up a cronjob?
- How can PHP developers improve the efficiency and security of their login scripts when retrieving user data from a text file?
- What is the purpose of the flock() function in PHP and how can it help prevent data corruption in text files?