php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51448 class and define problem
Submitted: 2010-03-31 18:16 UTC Modified: 2013-02-18 00:34 UTC
From: antonello dot mangone at gmail dot com Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.3.2 OS: Sidux
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2010-03-31 18:16 UTC] 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();


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-16 03:55 UTC] crrodriguez at opensuse dot org
Do you have any zend extension loaded ?

Provide the output of php -m
 [2010-05-12 16:33 UTC] mike@php.net
-Status: Open +Status: Feedback
 [2010-05-12 16:33 UTC] mike@php.net
This should have been marked Feedback, shouldn't it?
 [2013-02-18 00:34 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Mon Aug 15 16:05:46 2022 UTC