Edit report at http://bugs.php.net/bug.php?id=51448&edit=1
ID: 51448
Comment by: crrodriguez at opensuse dot org
Reported by: antonello dot mangone at gmail dot com
Summary: class and define problem
Status: Open
Type: Bug
Package: *General Issues
Operating System: Sidux
PHP Version: 5.3.2
New Comment:
Do you have any zend extension loaded ?
Provide the output of php -m
Previous Comments:
------------------------------------------------------------------------
[2010-03-31 18:16:02] antonello dot mangone at gmail dot com
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();
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=51448&edit=1