|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68977 Regression with linebreaks returned from exec()
Submitted: 2015-02-03 10:36 UTC Modified: 2015-02-03 11:55 UTC
From: Assigned:
Status: Open Package: Program Execution
PHP Version: 5.4Git-2015-02-03 (Git) OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
Solve the problem:
40 - 1 = ?
Subscribe to this entry?

 [2015-02-03 10:36 UTC]
exec() doesn't return empty lines from execution results as empty strings, but as newline characters.

Test script:

#!/usr/bin/env php
Line one
Line two

Line three
Line four


exec(__DIR__ . '/cmd.php', $result, $value);

Expected result:
array(5) {
  string(8) "Line one"
  string(8) "Line two"
  string(0) ""
  string(10) "Line three"
  string(9) "Line four"

Actual result:
array(5) {
  string(8) "Line one"
  string(8) "Line two"
  string(1) "
  string(10) "Line three"
  string(9) "Line four"


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-03 10:52 UTC]
I think I've seen the same issue for release version.
It would be nicer add this to the bug report.
 [2015-02-03 11:55 UTC]
I tried with 5.6 from rasmus' vagrant box, and the bug wasn't there.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Tue Feb 25 10:01:23 2020 UTC