View Issue Details

IDProjectCategoryView StatusLast Update
0000470PHP for OS/2, ArcaOS & eComStation (PHP versions v8.x v7.x v5.x)Bugpublic2022-05-14 07:05
Reporterrgehrig Assigned Topsmedley  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionwon't fix 
PlatformPCOSeCSOS Version2.0
Summary0000470: Incorrect functionality of fputs and fwrite
DescriptionDoes not appear to put out a newline
Steps To Reproduce<?php
  $TeamsFile = 'teams.txt';
  $fp = fopen($TeamsFile, 'w');
  $theLeagueO = 'Spring 2011\n';
  fwrite($fp, $theLeagueO, strlen($theLeagueO));
  $theLeagueO = 'Spring 2012\n';
  fputs($fp, $theLeagueO, strlen($theLeagueO));
  fclose($fp);
?>

teams.txt contains Spring 2011\nSpring 2012\n
not
Spring 2011
Spring 2012
TagsNo tags attached.

Activities

rgehrig

2011-04-06 07:27

reporter   ~0001869

If I change it to the following it works. Changed ' to " around \n
<?php
  $TeamsFile = 'teams.txt';
  $fp = fopen($TeamsFile, 'w');
  $theLeagueO = 'Spring 2011;
  $theLeagueO = $theLeagueO . "\n";
  fwrite($fp, $theLeagueO, strlen($theLeagueO));
  $theLeagueO = 'Spring 2012;
  $theLeagueO = $theLeagueO . "\n";
  fputs($fp, $theLeagueO, strlen($theLeagueO));
  fclose($fp);
?>
Then the file contains
Spring 2011
Spring 2012

psmedley

2011-04-10 08:22

administrator   ~0001870

Which PHP version?

rgehrig

2011-04-10 16:46

reporter   ~0001871

Sorry it is PHP 5.2.13

rgehrig

2011-04-10 17:14

reporter   ~0001872

Further testing now on PHP 5.2.14
The following code works in that it puts out a newline
The teamsta.txt file looks like this
Spring 2011
Spring 2012
<?php
  $TeamsFile = 'teamsta.txt';
  $fp = fopen($TeamsFile, 'w');
  $theLeagueO = 'Spring 2011';
  $theLeagueO = $theLeagueO . "\n";
  fwrite($fp, $theLeagueO, strlen($theLeagueO));
  $theLeagueO = 'Spring 2012';
  $theLeagueO = $theLeagueO . "\n";
  fputs($fp, $theLeagueO, strlen($theLeagueO));
  fclose($fp);
?>

The following code does not put out a newline.
File teamsta1.txt contains
Spring 2011\nSpring 2012\n
<?php
  $TeamsFile = 'teamsta1.txt';
  $fp = fopen($TeamsFile, 'w');
  $theLeagueO = 'Spring 2011';
  $theLeagueO = $theLeagueO . '\n';
  fwrite($fp, $theLeagueO, strlen($theLeagueO));
  $theLeagueO = 'Spring 2012';
  $theLeagueO = $theLeagueO . '\n';
  fputs($fp, $theLeagueO, strlen($theLeagueO));
  fclose($fp);
?>
Not sure if this is the correct behavior as I have seen examples online of both that are said to work.

psmedley

2022-05-14 07:05

administrator   ~0004277

Please retest with a supported build of PHP (ie 7.4 or above)

Issue History

Date Modified Username Field Change
2011-04-06 07:17 rgehrig New Issue
2011-04-06 07:27 rgehrig Note Added: 0001869
2011-04-10 08:22 psmedley Note Added: 0001870
2011-04-10 16:46 rgehrig Note Added: 0001871
2011-04-10 17:14 rgehrig Note Added: 0001872
2022-05-14 07:05 psmedley Assigned To => psmedley
2022-05-14 07:05 psmedley Status new => resolved
2022-05-14 07:05 psmedley Resolution open => won't fix
2022-05-14 07:05 psmedley Note Added: 0004277
2022-05-14 07:05 psmedley Status resolved => closed