mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Adding that nice version_compare function, with examples
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@61976 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
0f44bdbf60
commit
eef467984d
1 changed files with 65 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.71 $ -->
|
||||
<!-- $Revision: 1.72 $ -->
|
||||
<reference id="ref.info">
|
||||
<title>PHP options & information</title>
|
||||
<titleabbrev>PHP options/info</titleabbrev>
|
||||
|
@ -1483,7 +1483,8 @@ echo "Current PHP version: ".phpversion();
|
|||
</example>
|
||||
</para>
|
||||
<para>
|
||||
See also <function>phpinfo</function>,
|
||||
See also <function>version_compare</function>,
|
||||
<function>phpinfo</function>,
|
||||
<function>phpcredits</function>,
|
||||
<function>php_logo_guid</function>,
|
||||
<function>zend_version</function>.
|
||||
|
@ -1723,6 +1724,68 @@ putenv ("UNIQID=$uniqid");
|
|||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.version-compare">
|
||||
<refnamediv>
|
||||
<refname>version_compare</refname>
|
||||
<refpurpose>Compares two "PHP-standardized" version number strings</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title>Description</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>int <function>version_compare</function></funcdef>
|
||||
<paramdef>string <parameter>version1</parameter></paramdef>
|
||||
<paramdef>string <parameter>version2</parameter></paramdef>
|
||||
<paramdef>string
|
||||
<parameter>
|
||||
<optional>operator</optional>
|
||||
</parameter>
|
||||
</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
<function>version_compare</function> compares
|
||||
two "PHP-standardized" version number strings. This
|
||||
is useful if you would like to write programs working
|
||||
only on some versions of PHP.
|
||||
</para>
|
||||
<para>
|
||||
<function>version_compare</function> returns -1 if
|
||||
the first version is lower than the second, 0 if they
|
||||
are equal, and +1 if the second is lower.
|
||||
</para>
|
||||
<para>
|
||||
If you specify the third optional
|
||||
<parameter>operator</parameter> argument, you
|
||||
can test for a particular relationship. The possible
|
||||
operators are: <literal><</literal>,
|
||||
<literal>lt</literal>, <literal><=</literal>,
|
||||
<literal>le</literal>, <literal>></literal>,
|
||||
<literal>gt</literal>, <literal>>=</literal>,
|
||||
<literal>ge</literal>, <literal>==</literal>,
|
||||
<literal>=</literal>, <literal>eq</literal>,
|
||||
<literal>!=</literal>, <literal><></literal>,
|
||||
<literal>ne</literal> respectively. Using
|
||||
this argument, the function will return 1 if
|
||||
the realtionship is the one specified by the
|
||||
operator, 0 otherwise.
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title><function>version_compare</function> example</title>
|
||||
<programlisting role="php">
|
||||
// prints -1
|
||||
echo version_compare("4.0.4", "4.0.6");
|
||||
|
||||
// the all print 1
|
||||
echo version_compare("4.0.4", "4.0.6", "<");
|
||||
echo version_compare("4.0.6", "4.0.6", "eq");
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<refentry id="function.zend-logo-guid">
|
||||
<refnamediv>
|
||||
<refname>zend_logo_guid</refname>
|
||||
|
|
Loading…
Reference in a new issue