Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

php variable circular reference

 
Php Variable Circular References

Circular-references has been a long outstanding issue with PHP. They are
caused by the fact that PHP uses a reference counted memory allocation
mechanism for its internal variables. This causes problems for longer
running scripts (such as an Application Server
or
the eZ Components
test-suite) as the memory is not freed until the end of the request. But
not everybody is aware on what exactly the problem is, so here is a
small introduction to circular references in PHP.

In PHP a refcount value is kept for every variable container (zval).
Those containers are pointed to from a function's symbol table that
contains the names of all the variables in the function's scope. Every
variable, array element or object property that points to a zval will
increase its refcount by one. The refcount of a zval container is
decreased by one whenever call unset() on a variable name that points to
it, or when a variable goes away because the function in which it was
used ends. For a more thorough explanation about references, please see
the article on this
that I
wrote for php|architect
some time
ago.

The problems with circular references all start by creating an array or
an object:

<?php
$tree = array( 'one' );
?>
This creates the following structure in memory:


Now if we proceed to add a new element to the array, that points back to
the array with:

<?php
$tree[] = $tree;
?>
We create a circular reference like this:


As you can see there are two variable names pointing to the array
itself. Once through the $tree variable, and once through the 2nd
element of the array. Because there are two variable names pointing to
the container, its refcount is 2.

Now, the next step that actually creates the problem if we unset() the
$tree variable. As I mentioned before an unset() on a variable name will
decrease the refcount of the variable container the variable poi


Ïà¹ØÎĵµ£º

linuxϰ²×°PHP APACHE MYSQL ÊÖ¼Ç

/**********************************
APACHE
***********************************/
±à¼­²ÎÊý£º
./configure" \
"--prefix=/usr/local/apache" \
"--enable-so" \
"--enable-ssl" \
"--enable-mods-shared=most" \
"--with-mpm=event" \
"--with-ssl=/usr/local/openssl" \
"--enable-cache" \
"--enable-mem- ......

PHPµ¥Ë«ÒýºÅµÄÎÊÌâ

»ù´¡ÎÊÌâ:
×î½ü±»µ¥Ë«ÒýºÅÀ§ÈÅ×Å£¬²»ÖªµÀʲôʱºòÓÃË«ÒýºÅ£¬Ê²Ã´Ê±ºòÓõ¥ÒýºÅ¡£×ܽáÇø·ÖÒ»ÏÂ
Ôڴ󲿷ÝÓïÑÔÖУ¬ÒýºÅÒýÆðÀ´µÄÄÚÈݶ¼±íʾΪ×Ö·û¡£
ÀýÈ磺
      <a href="µØÖ·">Á´½Ó</a>
      echo "×Ö·û´®";
      print("×Ö ......

³õѧPHP½Ó¿Ú

¼Ì³ÐÌØÐÔ¼ò»¯Á˶ÔÏó£¬ÀàµÄ´´½¨£¬Ôö¼ÓÁË´úÂëµÄÖØÓÃÐÔ¡£µ«ÊÇPHPÖ®Ö§³Öµ¥¼Ì³Ð¡£Èç¹ûÏëʵÏÖ¶à¼Ì³ÐµÄ»°¾ÍÒªÓõ½PHPµÄ½è¿Ú¡£PHP¿ÉÊÇʵÏÖ¶à¸ö½Ó¿Ú¡£
²»ÒªÓÃpublicÒÔÍâµÄ¹Ø¼ü×ÖÀ´ÐÞÊνӿÚÖеÄÀà³ÉÔ±¡£¶ÔÓÚ·½·¨£¬²»Ð´¹Ø¼ü×ÖÒ²¿ÉÒÔ¡£ÕâÊÇÒ»¸ö½è¿ÚÀà×ÔÉíµÄÌìÐÔ¾ö¶¨µÄ¡£ÄÇôÎÒÏëËûÊÇÎªÊ²Ã´ÄØ£¿
¶ÔÓÚ½Ó¿ÚÀ´Ëµ£¬Ëü²»ÄÜÓÃprotected,ºÍpr ......

phpÅäÖÃÎļþÏê½â

[PHP]
;;;;;;;;;;;;;;;;;;;
; About php.ini   ;
;;;;;;;;;;;;;;;;;;;
; PHP's initialization file, generally called php.ini, is responsible for
; configuring many of the aspects of PHP's behavior.
; PHP attempts to find and load this configuration from a number of locations.
; The follo ......

phpÖÐʵÏÖ¶àÏß³Ì

phpÖÐʵÏÖ¶àÏß³Ì
PHPÖÐʵÏÖ¶àÏß³Ì? ¿´µ½Õâ¸ö±êÌâ ÄãÒ»¶¨ÒÔΪÎÒ·èÁË..µ«ÊÇÊÂʵÉÏÎÒÕæµÄÕâô×öÁË.
ÏÂÃæÊÇÎÒµÄһЩ×ö·¨ ÒѾ­ÊµÑé¹ý. ȷʵ¿ÉÒÔµÄ.
ÎÒÃÇÖªµÀPHP±¾ÉíÊDz»Ö§³Ö¶àÏß³ÌµÄ µ«ÊÇÎÒÃǵÄWEB·þÎñÆ÷ÊÇÖ§³Ö¶àÏ̵߳Ä.
Ò²¾ÍÊÇ˵¿ÉÒÔͬʱÈöàÈËÒ»Æð·ÃÎÊ. ÕâÒ²ÊÇÎÒÔÚPHPÖÐʵÏÖ¶àÏ̵߳Ļù´¡.
¼ÙÉèÎÒÃÇÏÖÔÚÔËÐеÄÊÇa.phpÕâ¸öÎ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ