php / php/doc-en

fputcsv does not escape escape characters

Open
#2,372 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
XML
Stars
596
Forks
890
Avg merge
1d 15h
Merged PRs (30d)
55

Description

$out = fopen('php://output', 'w');
fputcsv($out, array('ab\\'));
fclose($out);

Output:
"ab\"

This should be outputting an escaped backslash ("ab\\"). Likewise, explicitly named escape characters in a string will not be escaped. Eg:

$out = fopen('php://output', 'w');
fputcsv($out, array('a:b'), ",", "\"", ":");
fclose($out);

Output:
"a:b"

Tested on PHP 8.0 and 8.2

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the PHP documentation entry for fputcsv and review how it describes the escape character, using the two reported examples as checks. Update the relevant explanation or examples so backslashes and explicitly supplied escape characters are accurately documented, then verify the wording against the observed PHP 8.0 and 8.2 output.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
documentation
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.