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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC