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
 [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 12:01:30 2024 UTC