|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-10-09 14:26 UTC] googleguy@php.net
[2012-10-09 14:26 UTC] googleguy@php.net
-Package: Class/Object related
+Package: Documentation problem
[2012-10-09 14:28 UTC] googleguy@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: googleguy
[2012-10-09 14:28 UTC] googleguy@php.net
[2012-10-09 14:37 UTC] olivier at m2mobi dot com
-Status: Closed
+Status: Assigned
-Package: Documentation problem
+Package: Class/Object related
[2012-10-09 14:37 UTC] olivier at m2mobi dot com
[2012-10-09 14:40 UTC] googleguy@php.net
-Status: Assigned
+Status: Closed
-Package: Class/Object related
+Package: Documentation problem
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Oct 27 08:00:01 2025 UTC |
Description: ------------ Implemented abstract function with additional parameter having default value doesn't cause any error. Will output: I am the first arg. I am the additional arg. I am the first arg. I am the additional arg default value. If no default value the script crash. Test script: --------------- <?php abstract class AbstractMother { public abstract function methodWithOneArg( $arg ); } class ConcreteChild extends AbstractMother { public function methodWithOneArg($arg, $arg2="I am the additional arg default value.") { echo $arg." ".$arg2 ; } } $child = new ConcreteChild() ; $child->methodWithOneArg( "I am the first arg.", "I am the additional arg.") ; echo "<br>" ; $child->methodWithOneArg("I am the first arg.") ; Expected result: ---------------- FATAL ERROR thrown Actual result: -------------- Just works, addition of a third argument is ignored: <?php class ConcreteChild2 extends AbstractMother { public function methodWithOneArg($arg, $arg2="I am the additional arg default value.", $arg3="I am another arg default value.") { echo $arg." ".$arg2." ".$arg3 ; } } echo "<br>" ;echo "<br>" ; $child2 = new ConcreteChild2() ; $child->methodWithOneArg( "I am the first arg.", "I am the additional arg.", "I am the other additional arg") ; echo "<br>" ; $child->methodWithOneArg( "I am the first arg.", "I am the additional arg.") ; echo "<br>" ; $child->methodWithOneArg("I am the first arg.") ; ?> Will output: I am the first arg. I am the additional arg. I am the first arg. I am the additional arg. I am the first arg. I am the additional arg default value.