[DOC-CVS] [doc-en] master: Sync, indent and update fgetcsv escape parameter description. (#5111)
[email protected] (alfsb via GitHub)
| Newsgroups | php.doc.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: alfsb (alfsb) Committer: GitHub (web-flow) Pusher: Girgias Date: 2026-01-15T16:58:24Z Commit: https://github.com/php/doc-en/commit/0a3648a71895f35f570573d31ca9e003786aa993 Raw diff: https://github.com/php/doc-en/commit/0a3648a71895f35f570573d31ca9e003786aa993.diff Sync, indent and update fgetcsv escape parameter description. (#5111) Co-authored-by: André L F S Bacci <[email protected]> Changed paths: M reference/filesystem/functions/fgetcsv.xml M reference/spl/splfileobject/fgetcsv.xml Diff: diff --git a/reference/filesystem/functions/fgetcsv.xml b/reference/filesystem/functions/fgetcsv.xml index 856f305b70db..22fc493fe5f5 100644 --- a/reference/filesystem/functions/fgetcsv.xml +++ b/reference/filesystem/functions/fgetcsv.xml @@ -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> diff --git a/reference/spl/splfileobject/fgetcsv.xml b/reference/spl/splfileobject/fgetcsv.xml index f3ba803a6371..c81087c9f179 100644 --- a/reference/spl/splfileobject/fgetcsv.xml +++ b/reference/spl/splfileobject/fgetcsv.xml @@ -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