Be a Supporter!

A problem with eval()

  • 369 Views
  • 5 Replies
New Topic Respond to this Topic
NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
A problem with eval() 2006-11-11 06:05:14 Reply

Hey guys, it's been a few days since I was here. Tom was talking about potential username "lockdown" so I swaped my username. It's me - SexOnStreet (Nino).

Alright, here we go:
I need to make a variable via eval() - user defines the name of that variable via $op['var'].

I came with this:
ob_start();
echo $op['var'];
$gotop = ob_get_contents();
eval("ob_get_contents() = $op1.$string.$op2;");
ob_end_clean();

But IT doesn't work -- $op['var'] is nicely filled with, for example, $dtxt. But the variable isn't made.

Suggestions, please?

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to A problem with eval() 2006-11-11 06:09:02 Reply

And yes, I know that third line isn't necessary.

henke37
henke37
  • Member since: Sep. 10, 2004
  • Offline.
Forum Stats
Member
Level 30
Blank Slate
Response to A problem with eval() 2006-11-11 07:37:28 Reply

Why are you using eval? If you ask me it should at the very lest come dissabled by default.


Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.

NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to A problem with eval() 2006-11-11 11:40:00 Reply

At 11/11/06 07:37 AM, henke37 wrote: Why are you using eval? If you ask me it should at the very lest come dissabled by default.

Then how would I do that?

1) User supplies an argument in a function.
2) I gotta make that variable which is supplied in argument and fill it with string.

eval() is the only choice

authorblues
authorblues
  • Member since: Jun. 21, 2005
  • Offline.
Forum Stats
Member
Level 12
Blank Slate
Response to A problem with eval() 2006-11-11 16:48:44 Reply

At 11/11/06 11:40 AM, NinoGrounds wrote: eval() is the only choice

really? ever used double dollarsigns?

$myvariablename = 'bob';
$$myvariablename = 'tom';

echo $bob;
?>


BBS Signature
NinoGrounds
NinoGrounds
  • Member since: Nov. 28, 2005
  • Offline.
Forum Stats
Member
Level 19
Programmer
Response to A problem with eval() 2006-11-13 14:33:41 Reply

At 11/11/06 04:48 PM, authorblues wrote: really? ever used double dollarsigns?

nope