php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #23353 inline variable detection only handles one dereference
Submitted: 2003-04-25 17:21 UTC Modified: 2003-04-26 16:40 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: spagmoid at yahoo dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.3.1 OS: WinXP
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: spagmoid at yahoo dot com
New email:
PHP Version: OS:

 

 [2003-04-25 17:21 UTC] spagmoid at yahoo dot com
php is supposed to use "as much text as possible" when detecting variables in strings, but it stops at the first object.


$Obj->Prop = "purple";
$String = "text $Obj->Prop text";

result: text purple text

$Obj->Obj->Prop = "purple";
$String = "text $Obj->Obj->Prop text";

result: text object->Prop text

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-04-25 17:22 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.

.
 [2003-04-26 15:32 UTC] spagmoid at yahoo dot com
Yes, this is a bug.  Try again.
 [2003-04-26 15:55 UTC] pollita@php.net
Where are you getting the information that:

php is supposed to use "as much text as possible" when detecting
variables in strings, but it stops at the first object.


Is this in the manual somewhere?  If so that page should be updated.

For complex variable references in interpolated string you must encapsulate them in curly braces.  In your example try:

$String = "text {$Obj->Obj->Prop} text";

 [2003-04-26 16:02 UTC] spagmoid at yahoo dot com
Very well, break the documentation instead of fixing the code:

Chapter 7. Types
/strings

Simple syntax
If a dollar sign ($) is encountered, the parser will greedily take as much tokens as possible to form a valid variable name.
 [2003-04-26 16:03 UTC] spagmoid at yahoo dot com
If the parser accepts $A->B why can't it accept $A->B->C ?? come on.
 [2003-04-26 16:39 UTC] wez@php.net
PHP 4 does not (and will not) support this kind of dereferencing.

It *is* a feature of PHP 5; you are welcome to try a snapshot from http://snaps.php.net, but it is still beta.
 [2003-04-26 16:40 UTC] spagmoid at yahoo dot com
Hopefully someone will at least fix the docs then.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 11:01:31 2024 UTC