PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
silverbux
Forum Newbie
Posts: 9 Joined: Mon Aug 14, 2006 8:50 pm
Post
by silverbux » Wed Oct 18, 2006 10:02 pm
is this possible?
$var = 'name';
$this->$$var = 'mark';
echo($this->name);
John Cartwright
Site Admin
Posts: 11470 Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:
Post
by John Cartwright » Wed Oct 18, 2006 10:19 pm
Please read the forum descriptions before posting.
Moved to PHP Code.
And not to sound blunt, but have you even tried? There is nothing more fufilling than learning for yourself.
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Thu Oct 19, 2006 2:14 am
no its not possible, you can't use this when something is not in object context.
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098 Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia
Post
by Chris Corbyn » Thu Oct 19, 2006 8:01 am
If that was inside a class it would work yes. You may need curly braces around the variable-variable. i.e.
$this->{$$var}