[prev in list] [next in list] [prev in thread] [next in thread]
List: php-doc-cvs
Subject: [DOC-CVS] cvs: phpdoc /en/reference/strings/functions strpos.xml
From: "Herman Radtke" <hradtke () php ! net>
Date: 2008-09-09 5:00:50
Message-ID: cvshradtke1220936450 () cvsserver
[Download RAW message or body]
hradtke Tue Sep 9 05:00:50 2008 UTC
Modified files:
/phpdoc/en/reference/strings/functions strpos.xml
Log:
There was a lot of confusion in the user notes about the !== operator. An
example was added using the !== operator in hopes of clearing some of it up.
Each example now has its own example box and title as well.
http://cvs.php.net/viewvc.cgi/phpdoc/en/reference/strings/functions/strpos.xml?r1=1.15&r2=1.16&diff_format=u
Index: phpdoc/en/reference/strings/functions/strpos.xml
diff -u phpdoc/en/reference/strings/functions/strpos.xml:1.15 \
phpdoc/en/reference/strings/functions/strpos.xml:1.16
--- phpdoc/en/reference/strings/functions/strpos.xml:1.15 Sun Dec 2 01:08:17 2007
+++ phpdoc/en/reference/strings/functions/strpos.xml Tue Sep 9 05:00:50 2008
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.15 $ -->
+<!-- $Revision: 1.16 $ -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.strpos">
<refnamediv>
<refname>strpos</refname>
@@ -73,7 +73,7 @@
&reftitle.examples;
<para>
<example>
- <title><function>strpos</function> examples</title>
+ <title>Using boolean true</title>
<programlisting role="php">
<![CDATA[
<?php
@@ -89,7 +89,39 @@
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
}
+?>
+]]>
+ </programlisting>
+ </example>
+
+ <example>
+ <title>Using boolean false</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
+$mystring = 'abc';
+$findme = 'a';
+$pos = strpos($mystring, $findme);
+// The !== operator can also be used. Using != would not work as expected
+// because the position of 'a' is 0. The statement (0 != false) evaluates
+// to false.
+if ($pos !== false) {
+ echo "The string '$findme' was found in the string '$mystring'";
+ echo " and exists at position $pos";
+} else {
+ echo "The string '$findme' was not found in the string '$mystring'";
+}
+?>
+]]>
+ </programlisting>
+ </example>
+
+ <example>
+ <title>Using an offset</title>
+ <programlisting role="php">
+<![CDATA[
+<?php
// We can search for the character, ignoring anything before the offset
$newstring = 'abcdef abcdef';
$pos = strpos($newstring, 'a', 1); // $pos = 7, not 0
--
PHP Documentation Commits Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic