Anyone have an idea, if at all possible with PHP?
function foo($var) {
}
$hello = "World";
foo($hello);
Would give me this outlet
varName = $hello
varValue = World
EDIT
Since most people here βblameβ me for bad practices and global variables, Iβm going to talk more about why we are looking for this behavior.
the reason we look at this behavior is because we want to simplify the assignment of variables to our views.
In most cases, we do this to assign variables to our view.
$this->view->assign('products', $products);
$this->view->assign('members', $members);
Although it would be simpler and more understandable to simply be able to do the following and allow the view to be responsible for determining the name of the variable that the assigned data receives in our views.
$this->view->assign($products);
$this->view->assign($members);
source
share