What is the limitation of PHP regarding method overloading?
In PHP, method overloading is not supported as it is in some other programming languages. However, you can achieve similar functionality by using default parameter values and conditional logic within the method to handle different numbers or types of arguments.
class Example {
public function exampleMethod($arg1, $arg2 = null) {
if ($arg2 === null) {
// handle case with only one argument
} else {
// handle case with two arguments
}
}
}