1
0
mirror of https://github.com/php/doc-ja.git synced 2026-03-24 07:02:08 +01:00
Files
2020-12-05 21:54:55 +00:00

149 lines
3.5 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: e095023e408c8cb6378ae16bb6870343a3946919 Maintainer: hirokawa Status: ready -->
<!-- CREDITS: shimooka,mumumu -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.nl2br">
<refnamediv>
<refname>nl2br</refname>
<refpurpose>改行文字の前に HTML の改行タグを挿入する</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>nl2br</methodname>
<methodparam><type>string</type><parameter>string</parameter></methodparam>
<methodparam choice="opt"><type>bool</type><parameter>use_xhtml</parameter><initializer>&true;</initializer></methodparam>
</methodsynopsis>
<para>
<parameter>string</parameter> に含まれるすべての改行文字 (<literal>\r\n</literal>
<literal>\n\r</literal><literal>\n</literal> および <literal>\r</literal>)
の前に <code>&lt;br /&gt;</code> あるいは <code>&lt;br&gt;</code> を挿入して返します。
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>string</parameter></term>
<listitem>
<para>
入力文字列。
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>use_xhtml</parameter></term>
<listitem>
<para>
XHTML 準拠の改行を使うか否か。
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
変更後の文字列を返します。
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>nl2br</function> の使用法</title>
<programlisting role="php">
<![CDATA[
<?php
echo nl2br("foo isn't\n bar");
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
foo isn't<br />
bar
]]>
</screen>
</example>
<example>
<title><parameter>use_xhtml</parameter> パラメータを使い、妥当な HTML 形式のマークアップを生成する</title>
<programlisting role="php">
<![CDATA[
<?php
echo nl2br("Welcome\r\nThis is my HTML document", false);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
Welcome<br>
This is my HTML document
]]>
</screen>
</example>
<example>
<title>さまざまな改行文字</title>
<programlisting role="php">
<![CDATA[
<?php
$string = "This\r\nis\n\ra\nstring\r";
echo nl2br($string);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
This<br />
is<br />
a<br />
string<br />
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>htmlspecialchars</function></member>
<member><function>htmlentities</function></member>
<member><function>wordwrap</function></member>
<member><function>str_replace</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
-->