php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45789 Silent crash on duplicate method
Submitted: 2008-08-11 21:38 UTC Modified: 2008-08-11 22:45 UTC
From: DikMax at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: 5.2.6 OS: WinXP sp3
Private report: No CVE-ID: None
 [2008-08-11 21:38 UTC] DikMax at gmail dot com
Description:
------------
When write two methods with same name in one class PHP doesn't produce any error. It just silently stops processing on include

Reproduce code:
---------------
<?php

ini_set('display_errors', 1);
error_reporting(E_ALL | E_STRICT);

class ClassName
{
    public function method()
    {
        echo 1;
    }
    
    public function method()
    {
        echo 1;
    }
}

echo 2;

Expected result:
----------------
Some compiler or interpreter error

Actual result:
--------------
Nothing

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-11 21:53 UTC] johannes@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Please enable error reporting in your server, then you get a "Fatal error: Cannot redeclare ClassName::method()". Setting this in the script doesn'T work as the error is generated before the script executes.
 [2008-08-11 22:12 UTC] DikMax at gmail dot com
Ok.
Maybe I wrote bad example.

I have next options in php.ini:

error_reporting  =  E_ALL | E_STRICT
display_errors = On
display_startup_errors = On
log_errors = On

and it still produce no output (in Apache's error.log or browser window). First time I saw this thing when use include_once to other file. And PHP silently stops running on include class with duplicate methods.
 [2008-08-11 22:45 UTC] johannes@php.net
verify, using phpinfo(), that you're editing the correct php.ini and are not overwriting the settings somewhere.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 00:01:30 2024 UTC