reference/strings/functions/strncmp.xml
a3573c18b89fd32aca1c3924d3fd9568900b4a33
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strncmp">
3
+
<refentry xml:id="function.strncmp" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>strncmp</refname>
6
6
<refpurpose>Binary safe string comparison of the first n characters</refpurpose>
...
...
@@ -10,9 +10,9 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>int</type><methodname>strncmp</methodname>
13
-
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
14
-
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
15
-
<methodparam><type>int</type><parameter>len</parameter></methodparam>
13
+
<methodparam><type>string</type><parameter>string1</parameter></methodparam>
14
+
<methodparam><type>string</type><parameter>string2</parameter></methodparam>
15
+
<methodparam><type>int</type><parameter>length</parameter></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
This function is similar to <function>strcmp</function>, with the
...
...
@@ -29,7 +29,7 @@
29
29
<para>
30
30
<variablelist>
31
31
<varlistentry>
32
-
<term><parameter>str1</parameter></term>
32
+
<term><parameter>string1</parameter></term>
33
33
<listitem>
34
34
<para>
35
35
The first string.
...
...
@@ -37,7 +37,7 @@
37
37
</listitem>
38
38
</varlistentry>
39
39
<varlistentry>
40
-
<term><parameter>str2</parameter></term>
40
+
<term><parameter>string2</parameter></term>
41
41
<listitem>
42
42
<para>
43
43
The second string.
...
...
@@ -45,7 +45,7 @@
45
45
</listitem>
46
46
</varlistentry>
47
47
<varlistentry>
48
-
<term><parameter>len</parameter></term>
48
+
<term><parameter>length</parameter></term>
49
49
<listitem>
50
50
<para>
51
51
Number of characters to use in the comparison.
...
...
@@ -59,13 +59,51 @@
59
59
<refsect1 role="returnvalues">
60
60
&reftitle.returnvalues;
61
61
<para>
62
-
Returns &lt; 0 if <parameter>str1</parameter> is less than
63
-
<parameter>str2</parameter>; &gt; 0 if <parameter>str1</parameter>
64
-
is greater than <parameter>str2</parameter>, and 0 if they are
62
+
Returns <literal>-1</literal> if <parameter>string1</parameter> is less than
63
+
<parameter>string2</parameter>; <literal>1</literal> if <parameter>string1</parameter>
64
+
is greater than <parameter>string2</parameter>, and <literal>0</literal> if they are
65
65
equal.
66
66
</para>
67
67
</refsect1>
68
68

69
+
<refsect1 role="changelog">
70
+
&reftitle.changelog;
71
+
<informaltable>
72
+
<tgroup cols="2">
73
+
<thead>
74
+
<row>
75
+
<entry>&Version;</entry>
76
+
<entry>&Description;</entry>
77
+
</row>
78
+
</thead>
79
+
<tbody>
80
+
&standard.changelog.binary-safe-string-comparison;
81
+
</tbody>
82
+
</tgroup>
83
+
</informaltable>
84
+
</refsect1>
85
+

86
+
<refsect1 role="examples">
87
+
&reftitle.examples;
88
+
<para>
89
+
<example>
90
+
<title><function>strncmp</function> example</title>
91
+
<programlisting role="php">
92
+
<![CDATA[
93
+
<?php
94
+

95
+
$var1 = 'Hello John';
96
+
$var2 = 'Hello Doe';
97
+
if (strncmp($var1, $var2, 5) === 0) {
98
+
echo 'First 5 characters of $var1 and $var2 are equals in a case-sensitive string comparison';
99
+
}
100
+
?>
101
+
]]>
102
+
</programlisting>
103
+
</example>
104
+
</para>
105
+
</refsect1>
106
+

69
107
<refsect1 role="seealso">
70
108
&reftitle.seealso;
71
109
<para>
...
...
@@ -81,7 +119,6 @@
81
119
</refsect1>
82
120

83
121
</refentry>
84
-

85
122
<!-- Keep this comment at the end of the file
86
123
Local variables:
87
124
mode: sgml
88
125