mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
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. git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@266014 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
9fa2c902c0
commit
768a81cfaa
1 changed files with 34 additions and 2 deletions
|
@ -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 @@ if ($pos === false) {
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue