|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2010-04-16 03:55 UTC] crrodriguez at opensuse dot org
[2010-05-12 16:33 UTC] mike@php.net
-Status: Open
+Status: Feedback
[2010-05-12 16:33 UTC] mike@php.net
[2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 22 20:00:01 2025 UTC |
Description: ------------ Using php 5.3.2-1 I tried the following code and I found probably a bug that I don't know if it is a problem of the define function or if it's a problem of php. When I write the example 1, the first time the page print the echo message in the __construct. If I refresh the page the browser try to download or to open the php file. If I modify something in the file or if I stop and then start the apache web server (apache2) the previous behaviour is repeated. The problem is related to de definition of the constant EXAMPLE and the assignment of this constant to the attribute $variabile of the class Test. If as in the example 2 i define the constant EXAMPLE and then I set the property from the __construct method the problem is bypassed, but I think it should be solved. Test script: --------------- example 1 ---------------------------------------------------------------------------------- define('EXAMPLE', 0); class Test { public $variabile = EXAMPLE; public function __construct() { echo "instance of Test class created"; } } $newtest = new Test(); example 2 -------------------------------------------------------------------------------- define('EXAMPLE', 0); class Test { public $variabile = ""; public function __construct() { $this->variabile = EXAMPLE; echo "instance of Test class created"; } } $newtest = new Test(); Expected result: ---------------- example 2 -------------------------------------------------------------------------------- define('EXAMPLE', 0); class Test { public $variabile = ""; public function __construct() { $this->variabile = EXAMPLE; echo "instance of Test class created"; } } $newtest = new Test();