Why PHP Uses snake_case for Functions but camelCase for Methods: A Historical Look
PHP's naming conventions appear split because the language evolved in two distinct phases: early PHP relied on procedural, C-style built-in functions that naturally adopted snake_case, while later PHP 5 introduced object-oriented programming where camelCase methods became standard. Developer tanahiro2010 traced this divide through PHP's history, from Rasmus Lerdorf's 1994 origins to the influence of PEAR, major frameworks, and the PHP-FIG standards body. The PHP-FIG's PSR-1 standard codified camelCase for class methods but did not mandate a style for standalone functions, leaving the split intact. In practice, the author recommends snake_case for global and helper functions and camelCase for class methods, while stressing that project- or framework-specific conventions should always take priority. PHP itself enforces no naming rules at the interpreter level, meaning the split is a matter of community convention rather than technical requirement.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in