cvs: phpdoc /en/reference/strings/functions strpos.xml

From: Date: Tue, 09 Sep 2008 05:00:50 +0000
Subject: cvs: phpdoc /en/reference/strings/functions strpos.xml
Groups: php.doc.cvs 
Request: Send a blank email to doc-cvs+get-2146@lists.php.net to get a copy of this message
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

« previous php.doc.cvs (#2146) next »