Home > Backend Development > PHP Tutorial > 递归引用问题

递归引用问题

WBOY
Release: 2016-06-23 13:54:42
Original
997 people have browsed it

function array_format($data){    foreach($data as $k => &$v){        if(is_array($v)) {        	array_format(&$v); //这个是关键。在5.3版本可以使用.在5.4版本不能用。这个是什么问题?        }else{	        if(is_null($v)) $v = "";	        $v = htmlspecialchars_decode($v);        }    }    return $data;}
Copy after login


回复讨论(解决方案)

规则问题
Fatal error: Call-time pass-by-reference has been removed
致命错误:传递引用的做法已被废止
要这么写

function array_format(&$data){    foreach($data as $k => &$v){        if(is_array($v)) {            array_format($v);        }else{            if(is_null($v)) $v = "";            $v = htmlspecialchars_decode($v);        }    }    return $data;}
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template