TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 04-17-2008, 11:47 AM   #1 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default debug_zval_dump vs. var_dump

What is the difference between the two? They both show the same outputs pretty much. What is refcount, as in? Err, like the number of references to that variable?

Like so:
PHP Code:

$var1 
"Hello";
$var2 =& $var1;
$var3 =& $var1;

debug_zval_dump(&$var1); 

That will output a total number of 2 references? cause $var2 and $var3 are referencing $var1's variable.


So is that it? About var_dump and debug_zval_dump, one has refcount and the other doesn't? hmm..
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Old 04-22-2008, 11:02 PM   #2 (permalink)
Moderateur
RegEx Guru PHP Guru Top Contributor Advanced Programmer 
 
Salathe's Avatar
 
Join Date: Apr 2007
Posts: 1,393
Thanks: 5
Salathe is on a distinguished road
Default

After looking at the relevant PHP source code (in ext/standard/var.c for those interested) it appears as though your assumption is correct. debug_zval_dump simply displays the associated refcount whereas var_dump does not.

As for your code snippet, debug_zval_dump would report a refcount of 4, believe it or not. Once (1) for the first assignment of "Hello" to $var1. Another (2) for the assign-by-reference to $var2. Another (3) for the assign-by-reference to $var3. Finally another (4) reference is made when calling debug_zval_dump.
Salathe is offline  
Reply With Quote
The Following User Says Thank You to Salathe For This Useful Post:
Orc (04-22-2008)
Old 04-23-2008, 12:18 AM   #3 (permalink)
Orc
The Prestige
 
Orc's Avatar
 
Join Date: Dec 2007
Posts: 1,044
Thanks: 193
Orc is on a distinguished road
Default

Quote:
Originally Posted by Salathe View Post
After looking at the relevant PHP source code (in ext/standard/var.c for those interested) it appears as though your assumption is correct. debug_zval_dump simply displays the associated refcount whereas var_dump does not.

As for your code snippet, debug_zval_dump would report a refcount of 4, believe it or not. Once (1) for the first assignment of "Hello" to $var1. Another (2) for the assign-by-reference to $var2. Another (3) for the assign-by-reference to $var3. Finally another (4) reference is made when calling debug_zval_dump.
'

I guess that's because of me referencing in the arguments of the function?
__________________
VillageIdiot can have my babbies ;d
Orc is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 01:43 AM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design