Bug #55159 [Com]: fopen encodes ampersand '&' as '&'

From: Date: Fri, 08 Jul 2011 00:24:23 +0000
Subject: Bug #55159 [Com]: fopen encodes ampersand '&' as '&'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-161700@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=55159&edit=1

 ID:                 55159
 Comment by:         lonnyk at gmail dot com
 Reported by:        knappster_1 at hotmail dot com
 Summary:            fopen encodes ampersand '&' as '&'
 Status:             Open
 Type:               Bug
 Package:            Unknown/Other Function
 Operating System:   Unix
 PHP Version:        5.2.17
 Block user comment: N
 Private report:     N

 New Comment:

I tested this on the 5.4 alpha and did not have this problem.

Here is my test script:
----------------------
<?php
error_reporting(E_ALL);
$fh = fopen("http://finance.yahoo.com/d/quotes.csv?
s=ABT&f=sl1d1t1c1ohgvpnbaejkr&o=t", "r");
while( !feof( $fh ) ){
        echo fgets( $fh ) . "\n";
}

Result:
---------------------

"ABT",53.54,"7/7/2011","4:01pm",+0.26,53.49,53.60,53.24,4932482,53.28,"Abbott

Laboratori",N/A,N/A,2.87,44.59,54.24,18.56


Previous Comments:
------------------------------------------------------------------------
[2011-07-07 16:32:41] knappster_1 at hotmail dot com

Description:
------------
---
From manual page: http://www.php.net/function.fopen%23Parameters
---
The function used to return a csv file with a stock quote with PHP 5.2.9.  However, now with 5.2.17
the function will replace '&' with '&amp;' and it returns a csv file
with just the text: "Missing Format Variable".

It is easy to verify by using a malformed URL with '&' in it and on the resulting
html, view source and the error message will show '&amp;' where '&'
should be.  I have been unable to locate a workaround.  

Test script:
---------------
fopen("http://finance.yahoo.com/d/quotes.csv?s=ABT&f=sl1d1t1c1ohgvpnbaejkr&o=t",
"r");



------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=55159&edit=1


Thread (4 messages)

« previous php.bugs (#161700) next »