П О Р Т А Л                            
С Е Т Е В Ы Х                          
П Р О Е К Т О В                        
  
Поиск по сайту:
                                                 
Главная

О проекте

Web-мастеру
     HTML & JavaScript
     SSI
     Perl
     PHP
     XML & XSLT
     Unix Shell

MySQL

Безопасность

Хостинг

Другое








Самое читаемое:

Учебник PHP - "Для Чайника".
Просмотров 3513 раз(а).

Иллюстрированный самоучитель по созданию сайтов.
Просмотров 6115 раз(а).

Учебник HTML.
Просмотров 3271 раз(а).

Руководство по PHP5.
Просмотров 5492 раз(а).

Хостинг через призму DNS.
Просмотров 4129 раз(а).

Подборка текстов стандартных документов.
Просмотров 55769 раз(а).

Учебник PHP - Самоучитель
Просмотров 3085 раз(а).

Документация на MySQL (учебник & справочное руководство)
Просмотров 5646 раз(а).

Внешние атаки...
Просмотров 3835 раз(а).

Учебник PHP.
Просмотров 2822 раз(а).

SSI в примерах.
Просмотров 37459 раз(а).



 
 
| Добавить в избранное | Сделать стартовой | Помощь





Руководство по PHP
Пред. След.

debug_zval_dump

(PHP 4 >= 4.2.0, PHP 5)

debug_zval_dump -- Dumps a string representation of an internal zend value to output

Описание

void debug_zval_dump ( mixed variable )

Dumps a string representation of an internal zend value to output.

Список параметров

variable

The variable being evaluated.

Возвращаемые значения

Эта функция не возвращает значения после выполнения.

Примеры

Пример 1. debug_zval_dump() example

<?php
$var1
= 'Hello World';
$var2 = '';

$var2 =& $var1;

debug_zval_dump(&$var1);
?>

Результат выполнения данного примера:

string(11) "Hello World" refcount(3)

Beware the refcount: The refcount value returned by this function is non-obvious in certain circumstances. For example, a developer might expect the above example to indicate a refcount of 2. The third reference is created when actually calling debug_zval_dump().

This behavior is further compounded when a variable is not passed to debug_zval_dump() by reference. To illustrate, consider a slightly modified version of the above example:

Пример 2.

<?php
$var1
= 'Hello World';
$var2 = '';

$var2 =& $var1;

debug_zval_dump($var1); // not passed by reference, this time
?>

Результат выполнения данного примера:

string(11) "Hello World" refcount(1)

Why refcount(1)? Because a copy of $var1 is being made, when the function is called.

This function becomes even more confusing when a variable with a refcount of 1 is passed (by copy/value):

Пример 3.

<?php
$var1
= 'Hello World';

debug_zval_dump($var1);
?>

Результат выполнения данного примера:

string(11) "Hello World" refcount(2)

A refcount of 2, here, is extremely non-obvious. Especially considering the above examples. So what's happening?

When a variable has a single reference (as did $var1 before it was used as an argument to debug_zval_dump()), PHP's engine optimizes the manner in which it is passed to a function. Internally, PHP treats $var1 like a reference (in that the refcount is increased for the scope of this function), with the caveat that if the passed reference happens to be written to, a copy is made, but only at the moment of writing. This is known as "copy on write."

So, if debug_zval_dump() happened to write to its sole parameter (and it doesn't), then a copy would be made. Until then, the parameter remains a reference, causing the refcount to be incremented to 2 for the scope of the function call.


Пред. Начало След.
Variable Handling Functions Уровень выше doubleval


Если Вы не нашли что искали, то рекомендую воспользоваться поиском по сайту:
 





Copyright © 2005-2016 Project.Net.Ru