What is parameter signature in PHP?

The official PHP documentation explaining about extends in the classes and objects section says:

"When overriding methods, the parameter signature should remain the same or PHP will generate an E_STRICT level error. This does not apply to the constructor which allows overriding with different parameters." 

So I want to know what a parameter signature is?

example inside the documentation:

 <?php class ExtendClass extends SimpleClass { // Redefine the parent method function displayVar() { echo "Extending class\n"; parent::displayVar(); } } $extended = new ExtendClass(); $extended->displayVar(); ?> 

Official online link

+4
source share
1 answer

The signature of the parameter is simply the definition of the parameters in the definition (signature) of the method. What is meant by the quoted text is to use the same number (and type that is not applicable in PHP) of the parameter when overriding the method of the parent class.
The signature of the function / method is also called the head. It contains the name and parameters. The actual function code is called the body.

 function foo($arg1, $arg2) // signature { // body } 

So, for example, if you have the foo($arg1, $arg2) method in the parent class, you cannot override it in the extended class by specifying the foo($arg) method.

+4
source

All Articles