|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #53215 Method overload on PHP
Submitted: 2010-11-01 01:34 UTC Modified: 2010-11-01 18:27 UTC
From: jonimane at gmail dot com Assigned:
Status: Not a bug Package: Class/Object related
PHP Version: Irrelevant OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
33 - 4 = ?
Subscribe to this entry?

 [2010-11-01 01:34 UTC] jonimane at gmail dot com
Can you implements overload methods?

look test script x.x

my english is so so bad, sorry.

if you didn't understand me, i can explain you x.x


Test script:
class Test
  public function hello()
    echo "hello";

  public function hello($name)
    echo "hello {$name}";

$c = new Test;
$c->hello(); // print "hello"
$c->hello("PHP"); // print "hello PHP"

Expected result:
don't give errors and method overload work

Actual result:
Fatal error: Cannot redeclare Test::hello() in C:\...\Test.php on line 9


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-11-01 04:55 UTC]
-Status: Open +Status: Bogus
 [2010-11-01 04:55 UTC]
Not adequate to PHP for several reasons:

* Type of arguments cannot be provided expect in limited circumstances, and even then it's not required.
* The only differentiating factor would be the number of arguments, but in PHP a function can take more arguments than it declares, so even then...
 [2010-11-01 18:27 UTC] jonimane at gmail dot com
hm =/

To polymorphism would greatly help

function t(Test $t)

function t(NoTest $t)

so, thank you anyway =]

if it were implemented would be great *-*

thx again =]
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 16:01:31 2024 UTC