Re: Name of variable to string [SOLVED]
| From: | Jochem Maas | Date: | Fri, 08 Feb 2008 21:42:16 +0000 |
| Subject: | Re: Name of variable to string [SOLVED] | ||
| References: | 1 2 3 4 5 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-268989@lists.php.net to get a copy of this message | ||
Daniel Brown schreef:
On Feb 8, 2008 4:17 PM, tedd <tedd.sperling@gmail.com> wrote:I don't see why this has to be so convoluted - it would be a heck of a lot easier to do it with a string: $post_var = @sessionize_post('post_var'); so why exactly is that not an option (or good idea)?At 10:31 AM -0500 2/8/08, Daniel Brown wrote:On Feb 8, 2008, at 10:14 AM, tedd wrote: Hi gang: From a variable with the name of $this_variable -- how do I get astring 'this_variable' ?BINGO! We have a winner! For those of you who want to know what I'm doing with the solution, please review: http://www.webbytedd.com/bbbb/var-string/index.php Warning: Geek meters should be worn at all times and exposure should be limited. All code is shown. The "problem" that I was seeking a solution for was simply an easier way to grab POST and GET variables and place them into SESSIONs while keeping the most current values current. I'm a little disappointed in the solution because I wanted the statements to be: $post_var = sessionize_post($post_var); $get_var = sessionize_get($ger_var); But, the function provided by Daniel (and found in the literature) would not work from within my session_post and session_get functions -- I think it's probably something to do with the scope of the variable. In any event, I had to alter the calls to:What Tedd means is this: ;-P$post_var = @sessionize_post($post_var, vname($post_var)); $get_var = @sessionize_get($get_var, vname($get_var));
You see, there can be reasons why someone would want to know the variable's name. Thanks Daniel and to all who commented.And thank you for putting credit where it was really due. I knewI had gotten that code a couple of years ago from somewhere, but couldn't remember where. I hadn't written it, only modified it. I'm going to update my code now to put the "thanks to" section in there to the person who deserves the credit: Lucas Karisny (lucas dot karisny at linuxmail dot org).I had tried to find that each time I referenced the code or usedit myself, but never did. If only I had R'd TFM. :-\