Jump to content

User-defined variable set


therealwesfoster

Recommended Posts

Here's what I'm trying to do.

 

<?php
$do = 100;

function setVar($var,$value)
{
  return eval("\$var = $value");
}

setVar("do",300);

echo $do; // I want it to echo 300. Instead of the original 100
?>

 

I'm not using the eval right I'm sure. So my question is, how would i be able to set a variable this way? I'm building a class and thats why I'm wanting a function like this.

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/97898-user-defined-variable-set/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.