PHP How to set $variable = "$_GET['name']"

PHP How to set $variable = “$_GET[‘name’]”;

The goal is to update a variable into having the same information as what is used in the query string.

when I try to run my code I get this error:
Parse error: syntax error, unexpected ‘’ (T_ENCAPSED_AND_WHITESPACE), expecting ‘-’ or identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING)

So little information…

Please post the problematic script and don’t forget to enclose inside </> or starting and finishing with ```

Better yet, tell us what the REAL problem is that you are trying to solve by doing this.

Does $variable = $_SERVER['QUERY_STRING'] do what you want?

Reference:
https://www.php.net/manual/en/reserved.variables.server.php

You don’t need the double quotes around $_GET['name']; it should just be $variable = $_GET['name'];.

All get parameters are strings by default, no need to wrap them in another string.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.