0
eval("\$data = $myvar('https://www.example.com/json/id='". $_GET['name'] ."'))';

This got me an error, how to concatenate it properly?

Aaron Musktin
  • 297
  • 3
  • 12

2 Answers2

0

Eval is dangerous, but for your specific question above, the quotes were off at the end, and myvar is supposed to be a function. See below:

eval('$data = myvar("https://www.example.com/json/id='. $_GET['name'] .'");');

If you use double quotes like "$data" then $data will first be evaluated and the result or value will be eval'd instead. This is one of the risks of using eval(). If you use double quotes, then escape the $ signs like so:

eval("\$data = myvar('https://www.example.com/json/id=". $_GET['name'] ."');");

Demo: IDEOne

Community
  • 1
  • 1
Drakes
  • 23,254
  • 3
  • 51
  • 94
0

eval("\$data = $myvar('https://www.example.com/json/id=". $_GET['name']."');");

  • 1
    Could you please elaborate more your answer adding a little more description about the solution you provide? – abarisone Jun 17 '15 at 06:54