php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10967 $x .= &someFunction();
Submitted: 2001-05-18 23:41 UTC Modified: 2001-07-09 08:37 UTC
From: fabiankessler at usa dot net Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.0.5 OS: win2k
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: fabiankessler at usa dot net
New email:
PHP Version: OS:

 

 [2001-05-18 23:41 UTC] fabiankessler at usa dot net
code i would like to use:

---cut---
function &someShit() {
  return 'foo';
}

$out = '';
for ($i = 1; $i <= 3; $i++) {
  $out .= &someShit() . "<br>\n";
}
echo $out;
---cut---


problem: 
parse error on line
  $out .= &someShit() . "<br>\n";
because .= and & don't work together.

so the workaround would be:
  $temp = &someShit() . "<br>\n";
  $out .= $temp;

problem here:
it prints out 'foofoofoo' and not
'foo<br>\nfoo<br>\nfoo<br>\n'

so the code finally looks like:

---cut---
function &someShit() {
  return 'foo';
}

$out = '';
for ($i = 1; $i <= 3; $i++) {
  $temp = &someShit();
  $out .= $temp . "<br>\n";
}
echo $out;
---cut---

is this the normal behavior?

fab


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-22 16:50 UTC] fabiankessler at usa dot net
uhm, well, the thing with the $temp var is useless. i see now that i cannot reference something into *a part* of something else.

but the silent loss of "<br>\n" is still a problem, imo.

fab

 [2001-06-12 15:36 UTC] jmoore@php.net
well your playing with references where they are not needed.. expect to get your fingers burnt.
 [2001-07-09 08:37 UTC] jeroen@php.net
This is nonsense, what do you expect of $x .=
&somefunction()? that the second part of $x gets referenced?
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 05 23:01:28 2025 UTC