php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50427 Can't predefine variables as objects inside a class
Submitted: 2009-12-09 15:39 UTC Modified: 2009-12-09 18:08 UTC
From: omri dot rules at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.3.1 OS: Windows XP
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: omri dot rules at gmail dot com
New email:
PHP Version: OS:

 

 [2009-12-09 15:39 UTC] omri dot rules at gmail dot com
Description:
------------
I've tried to predefine a variable inside a class as an instance of another class.
The result was a parse error.

Reproduce code:
---------------
<?php
class Foo {
	public $var = 1;
}

class Bar {
	public $obj = new Foo;
	public function __construct() {
		echo $this->obj->var;
	}
}
$a = new Bar;
?>

Expected result:
----------------
1

Actual result:
--------------
Parse error: parse error in C:\wamp\www\try.php on line 7

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun May 19 11:01:37 2024 UTC