php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #11596 More ways of passing by refrence
Submitted: 2001-06-20 21:36 UTC Modified: 2010-11-19 00:38 UTC
From: hewei at mail dot ied dot ac dot cn Assigned: jani (profile)
Status: Closed Package: *General Issues
PHP Version: 4.0.5 OS: any
Private report: No CVE-ID: None
 [2001-06-20 21:36 UTC] hewei at mail dot ied dot ac dot cn
As of 4.04, two new ways of reference passing is added:
func(new class()) and func(func2()) while func2 is defined as &func2(){...}. They are VERY good for OOP.

But if the following two syntaxes are also supported, it will be really good.

1.  func(&new class());
2.  $obj =& func_get_arg($i);

The first one will make this possible:

$row =& $table->add(&new TableRow("valign=top"));
$cell =& $row->add(&new TableData("width=50%"));

while add is defined as &add($obj) {...;return $obj;}

And the second will make this possible:

$cell -> add(&$text1, &$text2, &$text3, ...);
while add function is going to use variable number of arguments.

But I didn't count on the following syntax being supported too:

foreach ($arr as &$value) {...} ( since there is a walk-arround: $value =& $arr[$i] )

$cell =& $table->add(&new TableRow())->add(&new TableData())
{ since I may request to much :))

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-19 00:38 UTC] jani@php.net
-Status: Open +Status: Closed -Package: Feature/Change Request +Package: *General Issues -Assigned To: +Assigned To: jani
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 15:01:29 2024 UTC