易截截图软件、单文件、免安装、纯绿色、仅160KB

PHP 的引用变量问题

$xml = '../data/news.xml' ;
$qp = qp($xml, 'news_root')->children();
$arrData = array() ;
$i = 0 ;
foreach( $qp as $child )
{
print_r( $arrData );
echo "<br/>hi<br/>";
unset($arrSub);
$arrSub = array() ;
array_push( $arrData , &$arrSub );
print_r( $arrData );
echo "<br/>";
// $arrData[] = &$arrSub;
$child = $child->children() ;
foreach( $child as $item )
{
$arrSub[ $item->tag() ] = $item->text();
}
print_r( $arrData );
echo"<br/>";
}
上面的代码,注意 unset($arrSub) 这句.
我的本意是 $arrData 解析出xml的2层内容.
我用array_push压入一个引用的数组 arrSub ,
然后操作arrSub,等于修改arrData.
但是,这其实是有问题的.
显示arrData最后的内容全是最后一条xml内容的复制. (我的xml最后是空项,所以arrData是:[ [],[] ] ,而不是正确的: [ [data1,data2] , [] ]
当我用引用把arrSub压入arrData后,
一个循环过后,又遇到语句 $arrSub = array() ; 这就有问题了,这句话执行后, arrData里面的一个也变成了空的array.
所以必须解除引用 unset( $arrSub ) 就能解决问题.


相关文档:

how to install apache, PHP and MySQL on Linux

how to install apache, PHP and MySQL on Linux
This tutorial explains the installation of Apache web server, bundled with PHP and MySQL server on a Linux machine. The tutorial is primarily for SuSE 9.2, 9.3, 10.0 & 10.1 operating systems, but most of the steps ought to be valid for all Linux-lik ......

php socket 浏览器

<?PHP
/**
* patServer
* PHP socket server base class
* Events that can be handled:
*   * onStart
*   * onConnect
*   * onConnectionRefused
*   * onClose
*   * onShutdown
*   * onReceiveData
*
* @version 1.1
* @author &n ......

php八荣八耻

以动手实践为荣 , 以只看不练为耻;
以打印日志为荣 , 以单步跟踪为耻;
以空格缩进为荣 , 以制表缩进为耻;
以单元测试为荣 , 以人工测试为耻;
以模块复用为荣 , 以复制粘贴为耻;
以多态应用为荣 , 以分支判断为耻;
以Pythonic为荣 , 以冗余拖沓为耻;
以总结分享为荣 , 以跪求其解为耻; ......

FastCGI 不完全高级指南(PHP版,Windows平台)

一、FastCGI是什么?
FastCGI是语言无关的、可伸缩架构的CGI开放扩展,其主要行为是将CGI解释器进程保持在内存中并因此获得较高的性能。众所周知,CGI解释 器的反复加载是CGI性能低下的主要原因,如果CGI解释器保持在内存中并接受FastCGI进程管理器调度,则可以提供良好的性能、伸缩性、Fail- Over特性等等。
FastCGI的官 ......

完整的PHP图形验证码程序源码!


代码如下:
<?php
   /*   网站验证码程序
    *   运行环境: PHP5.0.18 下调试通过
    *   需要 gd2 图形库支持(PHP.INI中 php_gd2.dll开启)
    *&nbs ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号