mirror of
https://github.com/php/doc-ru.git
synced 2026-03-26 08:42:13 +01:00
155 lines
3.8 KiB
XML
155 lines
3.8 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
||
<!-- EN-Revision: e095023e408c8cb6378ae16bb6870343a3946919 Maintainer: shein Status: ready -->
|
||
<!-- Reviewed: no -->
|
||
<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><br /></code> или <code><br></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 — это вам не\n bar");
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
foo — это вам не<br />
|
||
bar
|
||
]]>
|
||
</screen>
|
||
</example>
|
||
<example>
|
||
<title>Генерирование корректной HTML-разметки с параметром <parameter>use_xhtml</parameter></title>
|
||
<programlisting role="php">
|
||
<![CDATA[
|
||
<?php
|
||
|
||
echo nl2br("Привет!\r\nЭтой мой HTML-документ", false);
|
||
|
||
?>
|
||
]]>
|
||
</programlisting>
|
||
&example.outputs;
|
||
<screen>
|
||
<![CDATA[
|
||
Привет!<br>
|
||
Этой мой HTML-документ
|
||
]]>
|
||
</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
|
||
-->
|