![]() |
From String to function
Code:
<?=$member->contact('email'); ?>Code:
<?=$member->contact('msn'); ?>it goes to this function Code:
class memberCode:
Notice: Undefined variable: member in "path" |
You haven't set $member and variables in '' doesn't get parsed, you have to remove them (you could use "", but if you only have the variable there's no point). Also if you want to return an object variable you need to use $this->member[$variable].
|
Just a small tip. Don't ever echo anything within your class. Your class is just there to provide you with functions to handle the DATA. Cause if you later want to change the way something is output, you have to edit inside the class, and that's not good.
Have it return the member's msn instead, and echo $member->contact('msn'). |
Oh and..
PHP Code:
PHP Code:
PHP Code:
|
Like the latter posts have stated, $member isnt defined anywhere in the scope of the called method, hence the notice about an undefined variable 'member'.
Also remove the single quotes from around $variable otherwise PHP will interpret that statement to be thus: 'Access the array element $variable within the $member array' and not 'Access the array element msn within the $member array' etc as you were intending. This is because in PHP a variable name witin single quotes will not be expanded out and as a result will be treated as a normal string. However if you were to use double quotes PHP would interpolate variable values in place of the variable names but in this case neither is needed, the variable name will do fine: PHP Code:
PHP Code:
Hope that helps. |
| All times are GMT. The time now is 06:42 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0