php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75276 password_hash docs have \n that causes confusion
Submitted: 2017-09-28 14:49 UTC Modified: 2017-09-28 15:28 UTC
Votes:3
Avg. Score:3.0 ± 0.8
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:3 (100.0%)
From: chris at sternal-johnson dot com Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2017-09-28 14:49 UTC] chris at sternal-johnson dot com
Description:
------------
---
From manual page: http://www.php.net/function.password-hash
---

The password_hash documentation includes a code example with a \n character concatenated after the hashed password.

echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";

This apparently causes some confusion to users, who think it's necessary.

https://stackoverflow.com/questions/46471880/php-function-to-use-password-hash-hash-or-md5-depending-on-availability

This example in the documentation would be just fine without the newline.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-09-28 14:54 UTC] peehaa@php.net
> This apparently causes some confusion to **users**

I only see a single instance of a confused user who lacks understanding of basic syntax.

Not sure whether this warrants the change tbh.
 [2017-09-28 15:06 UTC] chris at sternal-johnson dot com
Yes, it's a basic misunderstanding of PHP syntax. That said, in the comments, another high-rep SO PHP user states "Yeah I know. I've been in conversation with a few members here about it before." so it's more than one incident.
 [2017-09-28 15:27 UTC] peehaa@php.net
Can you submit you patch for review in the docs editor so I can commit it?
 [2017-09-28 15:27 UTC] salathe@php.net
Automatic comment from SVN on behalf of salathe
Revision: http://svn.php.net/viewvc/?view=revision&revision=343154
Log: remove confusing newlines in password_hash() examples (doc bug #75276)
 [2017-09-28 15:28 UTC] salathe@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: salathe
 [2017-09-28 15:28 UTC] salathe@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

The examples are inspired by an example on the crypt() page [1], where adding newlines made more sense due to the example outputting multiple lines.

For the sake of others who might fall in to the "should I include newlines when using password_hash()?" trap... I've taken them away from the examples on the password_hash() page.

Thanks for the bug report.


[1] http://php.net/manual/en/function.crypt.php
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 24 08:01:33 2024 UTC