View Issue Details

IDProjectCategoryView StatusLast Update
0000470PHP for OS/2, ArcaOS & eComStation (PHP versions v8.x v7.x v5.x)Bugpublic2022-05-14 16:35
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 16:57

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 17:52

administrator   ~0001870

Which PHP version?

rgehrig

2011-04-11 02:16

reporter   ~0001871

Sorry it is PHP 5.2.13

rgehrig

2011-04-11 02:44

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 16:35

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 16:47 rgehrig New Issue
2011-04-06 16:57 rgehrig Note Added: 0001869
2011-04-10 17:52 psmedley Note Added: 0001870
2011-04-11 02:16 rgehrig Note Added: 0001871
2011-04-11 02:44 rgehrig Note Added: 0001872
2022-05-14 16:35 psmedley Assigned To => psmedley
2022-05-14 16:35 psmedley Status new => resolved
2022-05-14 16:35 psmedley Resolution open => won't fix
2022-05-14 16:35 psmedley Note Added: 0004277
2022-05-14 16:35 psmedley Status resolved => closed