略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: Reading []

2024-05-02

Reading []

<?php
class XmlTest {

    function 
test_ref(&$test) {
        
$test "ok";
    }

    function 
test($test) { }

    function 
run() {
        
$ar = array();
        
$this->test_ref($ar[]);
        
var_dump($ar);
        
$this->test($ar[]);
    }
}

$o = new XmlTest();
$o->run();
?>

This should always have thrown a fatal E_ERROR, because [] cannot be used for reading in PHP. It is invalid code in PHP 4.4.2 and PHP 5.0.5 upward.

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/migration51.reading.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3