LeetCode
LeetCode copied to clipboard
Use types and elseif
Using type declarations (especially in conjunction with strict_types) can result in faster code, and is considered best practice in modern php code.
Php has an explicit elseif you can/should use instead of combining else with if. This is required by the PSR-12 coding standard, which is the most up to date version (used to be PSR-2) of the standard that is the closest thing there is to a standard accepted by the community of php programmers.