From:             
Operating system: Sidux
PHP version:      5.3.2
Package:          *General Issues
Bug Type:         Bug
Bug description:class and define problem

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 bug report at http://bugs.php.net/bug.php?id=51448&edit=1
-- 
Try a snapshot (PHP 5.2):            
http://bugs.php.net/fix.php?id=51448&r=trysnapshot52
Try a snapshot (PHP 5.3):            
http://bugs.php.net/fix.php?id=51448&r=trysnapshot53
Try a snapshot (PHP 6.0):            
http://bugs.php.net/fix.php?id=51448&r=trysnapshot60
Fixed in SVN:                        
http://bugs.php.net/fix.php?id=51448&r=fixed
Fixed in SVN and need be documented: 
http://bugs.php.net/fix.php?id=51448&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=51448&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=51448&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=51448&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=51448&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=51448&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=51448&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=51448&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=51448&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=51448&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51448&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51448&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=51448&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=51448&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=51448&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=51448&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=51448&r=mysqlcfg

Reply via email to