How can a variable be defined in a URL in PHP?
In PHP, variables can be defined in a URL by passing them as query parameters. This is done by appending a "?" to the URL followed by the variable name and value pairs separated by "&". These variables can then be accessed in PHP using the $_GET superglobal array. Example:
// URL: http://example.com/page.php?name=John&age=25
$name = $_GET['name']; // Retrieves the value of the 'name' variable from the URL
$age = $_GET['age']; // Retrieves the value of the 'age' variable from the URL
echo "Name: $name, Age: $age";