|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-08-07 08:09 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 09:00:01 2025 UTC |
Description: ------------ See also: 28444 PHP gives unexpected errors when creating an object. I understand that i'm constructing an object, and some properties aren't there yet for reading; but I would have expected $this->$$date to work exactly the same as $this->date_Created... I would also have thought that declaring the class with a value in the protected member vars meant that these variables are not empty! Reproduce code: --------------- class NexusJob { protected $date_Created = ''; //dateTime protected $appointment_Date = ''; //dateTime protected $valuation_Date = ''; //dateTime protected $inspection_Date = ''; //dateTime public function __construct() { $dates = array('date_Created', 'appointment_Date', 'valuation_Date', 'inspection_Date'); foreach ($dates as $date) { $this->$$date = date(DATE_W3C); } } } $nj = new NexusJob(); Expected result: ---------------- No errors Actual result: -------------- Fatal error: Cannot access empty property