summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/codeigniter/Common.php23
-rw-r--r--user_guide/changelog.html1
-rw-r--r--user_guide/general/common_functions.html12
3 files changed, 36 insertions, 0 deletions
diff --git a/system/codeigniter/Common.php b/system/codeigniter/Common.php
index 340be2454..39005f602 100644
--- a/system/codeigniter/Common.php
+++ b/system/codeigniter/Common.php
@@ -30,6 +30,29 @@
// ------------------------------------------------------------------------
/**
+* Determines if the current version of PHP is greater then the supplied value
+*
+* Since there are a few places where we conditionally test for PHP > 5
+* we'll set a static variable.
+*
+* @access public
+* @return bool
+*/
+ function is_php($version = '5.0.0')
+ {
+ static $_is_php;
+
+ if ( ! isset($_is_php[$version]))
+ {
+ $_is_php[$version] = (version_compare(PHP_VERSION, $version) < 0) ? FALSE : TRUE;
+ }
+
+ return $_is_php[$version];
+ }
+
+// ------------------------------------------------------------------------
+
+/**
* Tests for file writability
*
* is_writable() returns TRUE on Windows servers when you really can't write to
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index 7bf5028d3..1de9effe6 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -92,6 +92,7 @@ SVN Revision: </p>
<li>Modified <a href="general/errors.html">show_error()</a> to allow sending of HTTP server response codes.</li>
<li>Modified <a href="general/errors.html">show_404()</a> to send 404 status code, removing non-CGI compatible header() statement from error_404.php template.</li>
<li>Added set_status_header() to the <a href="general/common_functions.html">Common functions<a> to allow use when the Output class is unavailable.</li>
+ <li>Added is_php() to <a href="general/common_functions.html">Common functions</a> to facilitate PHP version comparisons.</p>
</ul>
</li>
</ul>
diff --git a/user_guide/general/common_functions.html b/user_guide/general/common_functions.html
index 980a5a969..1f4394424 100644
--- a/user_guide/general/common_functions.html
+++ b/user_guide/general/common_functions.html
@@ -59,6 +59,18 @@ Auto-loading Resources
<p>CodeIgniter uses a few functions for its operation that are globally defined, and are available to you at any point. These do not require loading any libraries or helpers.</p>
+<h2>is_php('<var>version_number</var>')</h2>
+
+<p>is_php() determines of the PHP version being used is greater than the supplied <var>version_number</var>.</p>
+
+<code>if (is_php('5.3.0'))<br />
+{<br />
+&nbsp;&nbsp;&nbsp;&nbsp;$str = quoted_printable_encode($str);<br />
+}</code>
+
+<p>Returns boolean <kbd>TRUE</kbd> if the installed version of PHP is equal to or greater than the supplied version number. Returns <kbd>FALSE</kbd> if the installed version of PHP is lower than the supplied version number.</p>
+
+
<h2>is_really_writable('<var>path/to/file</var>')</h2>
<p>is_writable() returns TRUE on Windows servers when you really can't write to the file as the OS reports to PHP as FALSE only if the read-only attribute is marked. This function determines if a file is actually writable by attempting to write to it first. Generally only recommended on platforms where this information may be unreliable.</p>