1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 08:42:13 +01:00
Files
archived-doc-ru/reference/strings/functions/stripos.xml
2023-08-12 16:11:55 +03:00

188 lines
5.9 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 71b1e926631d5f5bec9b2e2685553453349ae799 Maintainer: shein Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="function.stripos" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>stripos</refname>
<refpurpose>Возвращает позицию первого вхождения подстроки без учёта регистра</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type class="union"><type>int</type><type>false</type></type><methodname>stripos</methodname>
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>offset</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
Ищет позицию первого вхождения подстроки
<parameter>needle</parameter> в строке <parameter>haystack</parameter>.
</para>
<para>
В отличие от <function>strpos</function>, эта функция не
учитывает регистр символов.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>haystack</parameter></term>
<listitem>
<para>
Строка, в которой производится поиск.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>needle</parameter></term>
<listitem>
<para>
Строка для поиска.
</para>
&strings.parameter.needle.non-string;
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>offset</parameter></term>
<listitem>
<para>
Если этот параметр указан, то поиск будет начат с указанного количества символов с
начала строки. Если задано отрицательное значение, отсчёт позиции начала поиска
будет произведён с конца строки.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Возвращает позицию, в которой находится искомая строка, относительно
начала строки <parameter>haystack</parameter> (независимо от смещения (offset)).
Также обратите внимание на то, что позиция строки отсчитывается от 0, а не от 1.
</para>
<para>
Возвращает &false;, если искомая строка не найдена.
</para>
&return.falseproblem;
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
&strings.changelog.ascii-case-folding;
&strings.changelog.needle-empty;
<row>
<entry>8.0.0</entry>
<entry>
Передача целого числа (&integer;) в <parameter>needle</parameter> больше не поддерживается.
</entry>
</row>
<row>
<entry>7.3.0</entry>
<entry>
Передача целого числа (&integer;) в <parameter>needle</parameter> объявлена устаревшей.
</entry>
</row>
<row>
<entry>7.1.0</entry>
<entry>
Добавлена поддержка отрицательных значений <parameter>offset</parameter>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования <function>stripos</function></title>
<programlisting role="php">
<![CDATA[
<?php
$findme = 'a';
$mystring1 = 'xyz';
$mystring2 = 'ABC';
$pos1 = stripos($mystring1, $findme);
$pos2 = stripos($mystring2, $findme);
// Конечно, 'a' не входит в 'xyz'
if ($pos1 === false) {
echo "Строка '$findme' не найдена в строке '$mystring1'";
}
// Заметьте, что используется ===. Использование == не даст верного
// результата, так как 'a' в нулевой позиции.
if ($pos2 !== false) {
echo "Нашёл '$findme' в '$mystring2' в позиции $pos2";
}
?>
]]>
</programlisting>
</example>
</para>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
&note.bin-safe;
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>mb_stripos</function></member>
<member><function>str_contains</function></member>
<member><function>str_ends_with</function></member>
<member><function>str_starts_with</function></member>
<member><function>strpos</function></member>
<member><function>strrpos</function></member>
<member><function>strripos</function></member>
<member><function>stristr</function></member>
<member><function>substr</function></member>
<member><function>str_ireplace</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->