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
相关文档:
之前写的crud类实在比较简单(http://blog.csdn.net/yycai/archive/2009/12/15/5012353.aspx),重新封装了一下:
<?php
/**
* 自动化数据表操作类
* @example
* <code>
* $db = cls_crud::factory(array('table'=>'article'));
* $data = $db->get_block_list(array('category_id' => 3), ......
/**********************************
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- ......
执行以下语句:
var_dump(2147483647); // int
var_dump(
2147483648); // float
可以看到,php int型的最大值就是
2147483647,即231
-1,因为32位的最高位要用来表示正负。
再执行以下语句:
$u = sprintf("%u",
2147483648); # 更换为%b,%d试试
var_dump($u);
......
以前一直搞C++进行C/S开发,曾经的想法是如果有机会,学学搞网站和嵌入式开发
没想到找到工作的第2天就有了做网站的机会,也赚到了自己大学期间最高的一份工资,10天1000块
在什么的都不会的情况下,尽然答应人事处的老师一个星期写好网站的后台
我承认找到工作后自己是有点狂了,很多事没注意到,很多事后悔不了。。。
......
在DOS中进行MySQL的访问可能乱码的情况有三种,
首先,要做的是检查MySQL的配置,安装的时候选择utf-8的语言环境会省去很多的麻烦
1. 检查MySQL的服务端、客户端的语言设置是否为“utf8”,不是的话手动将my.int更改过来;
2. 在PHP进行第一次mysql_query之前设置使用连接的字符集为"SET N ......