|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
||||
|
||||
|
PHP-General - Dynamically set variables within function-scope?
Is there a variable array similar to the GLOBALS array except within the scope of the current function? I want to dynamically convert an Objects members into variables without having to declare each variable myself. I do not want to use an array. I want to do something like this, except instead of making them global, I would like the variables to be within the scope of the current function.
If that doesn't make sense, I want it to work something like this: PHP Code:
Except instead of setting globals I want to set them as variables within the scope of the "foozle" function.
__________________
"Java makes impossible things possible, but makes easy things difficult." - Somebody
|
|
#2
|
||||
|
||||
|
Using a combination of extract and get_object_vars, you can do this:
PHP Code:
-Dan
__________________
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002 |
|
#3
|
||||
|
||||
|
The object in question is actually a mysql object; the fields being returned are query information. I appreciate the advice and will check all my variable names before implementing this method. Thanks again =)
Last edited by tagmanadvance : May 8th, 2008 at 03:49 PM. |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > PHP Development > PHP-General - Dynamically set variables within function-scope? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|