> but what I want is to be able to pass any variable to a procedure and
> have the variable name and value printed by the procedure.

Because PHP passes arguments by value, you will be out of luck in most
cases -- by the time your debugging function sees the argument, it's no
longer tied to the calling scope. Michael Sims' example function works
only for variables in the global scope, which probably won't work for
anything complex enough to need its own debugging library.


> I'm trying to extend my library of debugging functions/procedures by
> having a procedure which can be used to "inspect" a variable whenever I
> call it.

You may find what you need in debug_backtrace(). Alternatively, just pass
the variable name along:
        function echo_var($varname, $varvalue) {
                printf("%s: %s\n", $varname, $varvalue);
        }

...Which isn't much of an improvement over a plain old echo/print. And if
that's good enough for Brian Kernighan, I'd hope it's good enough for you.

:D

---------------------------------------------------------------------
michal migurski- contact info and pgp key:
sf/ca            http://mike.teczno.com/contact.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to