I am trying to find a way of classifying different types of PHP functions. For example that fopen, fwrite, fclose and so on are all part of IO, and the MySQL functions and MySQLi class is all for mysql related things but something more automatic was wondering if there is some sort of function class mapping in PHP
In many languages, classes/methods/functions are organized into namespaces, which may be presented as a tree (namespace A.B
and namespace A.C
are logically grouped, while B.D
is not not).
PHP recently introduced namespaces for custom code, but the PHP core set of functions was always a mess, and will stay a mess: it won’t be organized into namespaces, because it would break all existent PHP code. Don’t expect any organization from a language where functions are totally inconsistent when it comes to their names or the order of arguments.
On the other hand, PHP documentation is excellent, and it helps you understanding how functions are grouped. For example, if I take the two groups you quoted in your question, you’ll find the functions related to strings on a dedicated page, and MySQL functions on another one. Those are conveniently organized into a tree: MySQL-related documentation is inside Vendor Specific Database Extensions section, which is in turn inside Database Extensions.
Note: be careful! The list of functions tell you what functions are in the same group, but doesn’t tell the relations with other groups. For example, it won’t tell that when manipulating strings such as user input, you should use Unicode variants, and it won’t tell that instead of accessing the MySQL database directly, you should use PDO.
4