mirror of
https://github.com/php/doc-ja.git
synced 2026-04-26 17:38:12 +02:00
4773312462
- WASM の example 修正 - number_format まわりの誤訳 - その他細かい修正全てに追随 https://github.com/php/doc-en/commits/master/reference/strings
180 lines
5.3 KiB
XML
180 lines
5.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 45042fef652f1b4e904e809fcbfcf31f6c60670b Maintainer: takagi Status: ready -->
|
|
<!-- Credits: mumumu -->
|
|
<refentry xml:id="function.substr-compare" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>substr_compare</refname>
|
|
<refpurpose>指定した位置から指定した長さの 2 つの文字列について、バイナリ対応で比較する</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>substr_compare</methodname>
|
|
<methodparam><type>string</type><parameter>haystack</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>needle</parameter></methodparam>
|
|
<methodparam><type>int</type><parameter>offset</parameter></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>int</type><type>null</type></type><parameter>length</parameter><initializer>&null;</initializer></methodparam>
|
|
<methodparam choice="opt"><type>bool</type><parameter>case_insensitive</parameter><initializer>&false;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>substr_compare</function> は、<parameter>haystack</parameter>
|
|
の <parameter>offset</parameter> 文字目以降の最大
|
|
<parameter>length</parameter> 文字を、<parameter>needle</parameter>
|
|
と比較します。
|
|
</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>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>offset</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
比較を開始する位置。
|
|
負の値を指定した場合は、文字列の最後から数えます。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>length</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
比較する長さ。デフォルト値は、
|
|
<parameter>haystack</parameter> の長さから <parameter>offset</parameter> を引いたものと
|
|
<parameter>needle</parameter> の長さのうち、長いほうです。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>case_insensitive</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>case_insensitive</parameter> が &true; の場合、
|
|
大文字小文字を区別せずに比較します。
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
&strings.comparison.return;
|
|
<para>
|
|
<parameter>offset</parameter> が
|
|
<parameter>haystack</parameter> と等しい
|
|
(PHP 7.2.18, 7.3.5 より前のバージョン) か、
|
|
<parameter>haystack</parameter> より長い場合、
|
|
もしくは <parameter>length</parameter>
|
|
が設定されていて0未満である場合、
|
|
<function>substr_compare</function>
|
|
は警告を表示して &false; を返します。
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
&standard.changelog.binary-safe-string-comparison;
|
|
<row>
|
|
<entry>8.0.0</entry>
|
|
<entry>
|
|
<parameter>length</parameter> は、nullable になりました。
|
|
</entry>
|
|
</row>
|
|
<row>
|
|
<entry>7.2.18, 7.3.5</entry>
|
|
<entry>
|
|
<parameter>offset</parameter> の値は、
|
|
<parameter>haystack</parameter> の長さと等しくても問題なくなりました。
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>substr_compare</function> の例</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo substr_compare("abcde", "bc", 1, 2), PHP_EOL; // 0
|
|
echo substr_compare("abcde", "de", -2, 2), PHP_EOL; // 0
|
|
echo substr_compare("abcde", "bcg", 1, 2), PHP_EOL; // 0
|
|
echo substr_compare("abcde", "BC", 1, 2, true), PHP_EOL; // 0
|
|
echo substr_compare("abcde", "bc", 1, 3), PHP_EOL; // 1
|
|
echo substr_compare("abcde", "cd", 1, 2), PHP_EOL; // -1
|
|
echo substr_compare("abcde", "abc", 5, 1), PHP_EOL; // -1
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>strncmp</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
|
|
-->
|