I cannot use file(), fopen(), include() to open a URL with PHP

Expand / Collapse
 
     

I cannot use file(), fopen(), include() to open a URL with PHP


Check whether you are specifying non standard http/https ports in your url. If it's standard port 80 or 443 already, check whether your server is running php 4.4.2.

php 4.4.2 introduced a blocker problem with fopen() and related functions (http://bugs.php.net/bug.php?id=36017)

In that case you can use sockets for file open.

Example. If you had

$viart_xml = fopen("http://www.viart.com/viart_shop.xml", "r");

Change it to

$viart_xml = fsockopen("www.viart.com", 80, $errno, $errstr, 12);

fputs($viart_xml, "GET /viart_shop.xml HTTP/1.0\r\n");

fputs($viart_xml, "Host: www.viart.com\r\n");

fputs($viart_xml, "Referer: http://www.viart.com\r\n");

fputs($viart_xml, "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\r\n\r\n");

If you are not sufficient with the coding. You can change your PHP version with Control Panel or contact our support for help.




Tags:
PHP




Add Your Comments


Name: *
Email Address:
Web Address:
Verification Code:
*
 

Details
Last Modified:12/24/2008 6:33 PM
Last Modified By: Mark
Type: How to fix a problem
Article not rated yet.
Article has been viewed 948 times.
Options