What is the correct syntax for passing multiple GET variables in a URL in PHP?
When passing multiple GET variables in a URL in PHP, you need to separate each variable with an ampersand (&). Each variable should be in the format key=value. For example, if you want to pass two variables, you would construct the URL like this: example.com/page.php?var1=value1&var2=value2.
// Constructing a URL with multiple GET variables
$var1 = 'value1';
$var2 = 'value2';
$url = 'example.com/page.php?var1=' . urlencode($var1) . '&var2=' . urlencode($var2);
// Redirect to the constructed URL
header('Location: ' . $url);
exit();
Keywords
Related Questions
- What are the potential drawbacks of using the wordwrap function in PHP for truncating text?
- How can JavaScript be utilized to print a PDF file generated by PHP within a web application?
- How can the number of rows in a result set be accurately determined when querying an Access database with PHP and ODBC?