php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4054 Strange behavior of class variables
Submitted: 2000-04-05 20:32 UTC Modified: 2002-09-30 18:14 UTC
From: DerMurx at gmx dot de Assigned:
Status: Not a bug Package: Other
PHP Version: 3.0.16 OS: Windows 95/98/NT
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: DerMurx at gmx dot de
New email:
PHP Version: OS:

 

 [2000-04-05 20:32 UTC] DerMurx at gmx dot de
Have a look at this piece of code:

class User {
  var $Name;
  var $Mail

  function SetUser() {
    $this->$Name = "Bill";
    $this->$Mail = "bill@whitehouse.gov";
    echo $this->$Name, ":", $this->$Mail;
  }
}

Maybe you will notice the mistake with the $ sign ($this->$Name instead of $this->Name, see bug report #60). But PHP doesn't print an error, it interprets the code and outputs this:
bill@whitehouse.gov:bill@whitehouse.gov
So, either PHP should produce an error, or there should be a better description of the missing $ sign in the "Classes and Objects" section of the documentation.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-09-30 18:14 UTC] hholzgra@php.net
you just descovered "variable variables"

http://www.php.net/manual/en/language.variables.variable.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 17:01:31 2024 UTC