View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000470 | PHP for OS/2, ArcaOS & eComStation (PHP versions v8.x v7.x v5.x) | Bug | public | 2011-04-06 07:17 | 2022-05-14 07:05 |
Reporter | rgehrig | Assigned To | psmedley | ||
Priority | normal | Severity | major | Reproducibility | always |
Status | closed | Resolution | won't fix | ||
Platform | PC | OS | eCS | OS Version | 2.0 |
Summary | 0000470: Incorrect functionality of fputs and fwrite | ||||
Description | Does 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 | ||||
Tags | No tags attached. | ||||
|
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 |
|
Which PHP version? |
|
Sorry it is PHP 5.2.13 |
|
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. |
|
Please retest with a supported build of PHP (ie 7.4 or above) |
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 |