Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #17043
| Newsgroups | comp.lang.php |
|---|---|
| Date | 2016-09-09 08:23 -0700 |
| References | <1192751562.072955.88220@i38g2000prf.googlegroups.com> <op.t0e3r7kx5bnjuv@metallium.lan> |
| Message-ID | <3aa14ac8-7d76-4fe2-bc89-dbda54846637@googlegroups.com> (permalink) |
| Subject | Re: print out variable name as well as its content |
| From | sendtorobert@gmail.com |
On Thursday, October 18, 2007 at 8:03:54 PM UTC-4, Rik Wasmus wrote: > On Fri, 19 Oct 2007 01:52:42 +0200, Summercool <Summercoolness@gmail.com> > wrote: > > > I wonder in PHP, can you have a function like > > > > print_debug($foo); > > > > and it will print out: > > > > $foo is: > > 3 > > > > that is, it will print out, most importantly, the variable name, as > > well as its content. > > > > No, as it's name should be of utter unimportance. > > (Somewhere in this group there's been given a 'solution' for this about a > year ago I think. It involved using debug_backtrace(), fopen()ing the file > and reading/parsing the line indicated in that array. Not anything you > should want to do.) > > As said, the variable name should be of no importance. If you're trying to > pinpoint changes in your script you can either use __FILE__ & __LINE__ > along with the output, of use the debug_backtrace() mentioned earlier in a > function to output the file & line it was called. > -- > Rik Wasmus This may be true in most cases, but I'm running into this situation now. It's a situation whereby I'm grabbing field names from a database and assigning them to a variable $X. I need to see as I pass through each field if it's giving the $X variable the name of each field as it's variable name. I'm trying to dynamically create variables based on those field names. I've done this, I think...but I need to test it. Simply doing an ECHO '$X'; only shows me "$X," which means what?...that it's not working or that it's simply treating ECHO '$X' as an explicit vs the actual variable name?
Back to comp.lang.php | Previous | Next — Next in thread | Find similar | Unroll thread
Re: print out variable name as well as its content sendtorobert@gmail.com - 2016-09-09 08:23 -0700 Re: print out variable name as well as its content "R.Wieser" <address@not.available> - 2016-09-09 17:57 +0200
csiph-web