ID: 42878 Updated by: [EMAIL PROTECTED] Reported By: rc at opelgt dot org -Status: Open +Status: Bogus Bug Type: Feature/Change Request Operating System: all PHP Version: 5.2.4 New Comment:
Your code makes the assumption that one wants to print_r a variable from the globals scope. print_r'ing a variable from a function won't work: <?php $a = "grhgchlkmehvzfvehe"; function foobar() { $a = array(1, 2, 5, 7, 8); print_rc("a"); } foobar(); ?> If such a limitation is acceptable for you: Put that to your default library and use it, for a regular, internal, PHP function such a limitation isn't acceptable. I hope we can end this now. Previous Comments: ------------------------------------------------------------------------ [2007-10-06 13:37:16] rc at opelgt dot org Description: ------------ My reason for writing was to make PHP a bit more comfortable. I dont want to spam. I have tried to email you besides this bug reporting system at [EMAIL PROTECTED] without success. You are doing your job for the same reason I do report this: idealism. I first didnt understood what you meant with "variable container" cause I have studied physics, not informatics. Now I see the problematic that only the value and not the name is given the function print_r. My native language isnt english but german. I dont know the internal means of PHP and if a method ".name" exists. I only wanted to say it would be nice. I think that is the critical point very often: first to say "Yes I understand you, what you want is a good idea, unfortunately its not so easy to realize." <?php function print_rc($variable_name) { global ${$variable_name}; echo "Array \$$variable_name\n {\n"; foreach(${$variable_name} as $key => $val) echo " [$key] => $val\n"; echo " }\n"; } $arr = array(1,2,3); print_rc('arr'); ?> This is doing what I want. And the problem is instead giving the value to the function (print_r) here (print_rc) the name is given. So my wish is incompatible with the current implementation of PHPs print_r. Its a pity. Its my part to give this suggestion and its your part to decide whether its a nice thing and when "yes" how that can be implemented. You can see now that with an optional second parameter in print_r (interpreting the given variable as a name) or an additional new php- function print_rc my wish is possible. With the recent implementation of print_r it may not be possible. I dont want to waste my time describing the current state. I want to give a suggestion for the future. Realisation isnt impossible. RĂ¼diger ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=42878&edit=1