The Function Method
By Brent Roose
<?php
class x {
function function() {
echo __METHOD__;
}
}
(new x)->function();
// x::function
?>
It is possible to name a method ‘function’. This is part of the relaxed keywords of PHP, which allows PHP keywords to be used as a method name.
Of course, it is also possible to create a function called method.
See Also
- method function [Try me]
PHP Features
Last updated: 10 September 2026