a problem with eval(), can anyone help me? thx
Posted: Wed Jan 14, 2009 9:42 am
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I am a beginner to php, and i got a problem with eval() function.
I hope the result of output is "i am peter", but now i got "i am Array['name']", , can anyone help me ? thx!!!
//========================================
code:
~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:
Posting Code in the Forums to learn how to do it too.
I am a beginner to php, and i got a problem with eval() function.
I hope the result of output is "i am peter", but now i got "i am Array['name']", , can anyone help me ? thx!!!
//========================================
code:
Code: Select all
<?php
class user
{
private $vars= array();
public function init()
{
$this->vars["name"] = "peter";
}
public function show()
{
$sayme = "i am $this->vars['name']";
eval("?>" . $sayme . "<?");
}
}
$me = new user();
$me->init();
$me->show();
?>~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: