if ( ! function_exists('is_php')){ function is_php($version = '5.0.0') { static $_is_php; $version = (string)$version; if ( ! isset($_is_php[$version])) { $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; } return $_is_php[$version]; }}
All functions are present.
if ( ! function_exists('is_php')){}
Such a structure, does this seem a little superfluous.
Reply content:
if ( ! function_exists('is_php')){ function is_php($version = '5.0.0') { static $_is_php; $version = (string)$version; if ( ! isset($_is_php[$version])) { $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE; } return $_is_php[$version]; }}
All functions are present.
if ( ! function_exists('is_php')){}
Such a structure, does this seem a little superfluous.
It is not redundant to the framework. It is possible that the user will load their function files before loading the file.
Of course not, this is to avoid the framework's own function and the developer's function conflicts.
Easy to expand.
The framework first loads the developer's functions and then loads the system functions.
Developers only need a function of the same name, they can override the system functions.
This is also a major selling point of CI.
possible
- Prevents duplicate declaration errors from occurring when this file is introduced multiple times
- Compatible with PHP versions that provide built-in functions
The code given conforms to the first case
If you think this is a problem, you can actually solve it through a namespace.
several PHP versions feature compatibility, avoid frame-to-band functions, and developers ' function conflicts for two reasons.
1,ci is a very leisurely (long) history of the framework, in the CI up in those years, PHP there is no namespace, many new features do not support
2, I think CI such design intention, certainly not is to allow the user to rewrite these functions, because to implement inheritance and rewrite, certainly is class convenient.
1. Pre-implement some functions that PHP does not implement but may implement in the future, avoiding conflicts
2. Resolve the recurring load problem.
is not redundant for the following reasons:
1. Backward compatibility, avoid the following PHP version implemented the same name function
2. Easy for developers to expand. Look at the CI documentation and know that if developers need to rewrite the functions provided by the framework, they just have to write the function name in the same way.
CI is not a fully object-oriented framework, preserving many public functions, and without the concept of namespaces, so the framework can be extensible with this approach.
If you want to erase these,
You can use namespaces
Otherwise, the name of the duplicate conflict will be