1
0
mirror of https://github.com/php/doc-en.git synced 2026-03-24 07:42:10 +01:00

Sync, indent and update fgetcsv escape parameter description. (#5111)

Co-authored-by: André L F S Bacci <ae@php.net>
This commit is contained in:
alfsb
2026-01-15 13:58:24 -03:00
committed by GitHub
parent a7428462fe
commit 0a3648a718
2 changed files with 14 additions and 24 deletions

View File

@@ -5,7 +5,7 @@
<refname>fgetcsv</refname>
<refpurpose>Gets line from file pointer and parse for CSV fields</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
@@ -88,15 +88,19 @@
It must be a single byte character or the empty string.
The empty string (<literal>""</literal>) disables the proprietary escape mechanism.
</para>
<warning>
<warning xml:id="function.fgetcsv..warn.escape.parameter">
<simpara>
Inside an <parameter>enclosure</parameter>, the <parameter>enclosure</parameter> character can always be <parameter>escaped</parameter> by doubling it,
resulting in a single <parameter>enclosure</parameter> character in the parsed result.
The <parameter>escaped</parameter> character works differently:
If it is followed by an <parameter>enclosure</parameter> character then that <parameter>enclosure</parameter> character will not be treated as one,
however the <parameter>escaped</parameter> character itself remains. So for the default parameters, <literal>""</literal>
inside an <parameter>enclosure</parameter> will be parsed into <literal>",</literal> while <literal>\"</literal> inside an
<parameter>enclosure</parameter> will be parsed into <literal>\"</literal>.
In the input stream, the <parameter>enclosure</parameter> character
can always be escaped by doubling it inside a quoted string,
resulting in a single <parameter>enclosure</parameter> character
in the parsed result.
The <parameter>escape</parameter> character works differently:
If a sequence of <parameter>escape</parameter> and
<parameter>enclosure</parameter> characters appear in the input,
both characters will be present in the parsed result.
So for the default parameters, a CVS line like
<literal>"a""b","c\"d"</literal> will have the fields parsed as
<literal>a"b</literal> and <literal>c\"d</literal>, respectively.
</simpara>
</warning>
<warning>

View File

@@ -55,21 +55,7 @@
<methodname>SplFileObject::setCsvControl</methodname>.
An empty string (<literal>""</literal>) disables the proprietary escape mechanism.
</para>
<warning>
<simpara>
In the input stream, the <parameter>enclosure</parameter> character
can always be escaped by doubling it inside a quoted string,
resulting in a single <parameter>enclosure</parameter> character
in the parsed result.
The <parameter>escape</parameter> character works differently:
If a sequence of <parameter>escape</parameter> and
<parameter>enclosure</parameter> characters appear in the stream,
both characters will be present in the parsed value.
So for the default parameters, <literal>""</literal>
in quoted strings will be parsed as <literal>"</literal>, while
<literal>\"</literal> parsed as <literal>\"</literal>.
</simpara>
</warning>
<xi:include xpointer="function.fgetcsv..warn.escape.parameter"/>
<warning>
<simpara>
As of PHP 8.4.0, depending on the default value of