How to print variable name?
Posted: Sun Oct 19, 2003 6:47 pm
Hello dear mates,
Take a look to this C++ code I use for debug purposes:
and it's output:
As you can see, #var prints the name of the variable. How would you do this in PHP?
Thanks,
Scorphus.
Take a look to this C++ code I use for debug purposes:
Code: Select all
#include <iostream>
using namespace std;
#define print_var(var) cout << #var << ": " << var << endl
int main (void) {
int foo = 123;
print_var(foo);
return 0;
}Code: Select all
foo: 123Thanks,
Scorphus.