PHP: FOPEN issue
Giorgio
-
Giorgio -
Giorgio -
Hello there,
I'm trying to parse XML files.
WEIRD...fopen couldn't open any http file while it's working fine with any local file.
I've tried the following:
________________________________________________________
1.
$fp = fopen("D:\Software\\test.txt","r");
while($data = fgets($fp, 400))
echo $data;
--> Result OK
2.
$fp = fopen("https://www.google.fr/?gws_rd=ssl","r");
while($data = fgets($fp, 400))
echo $data;
--> Result: Warning: fopen() [function.fopen]: php_network_getaddresses: gethostbyname failed in C:\wamp\www\hotelGlobe\hotels_list4.php on line 4
Warning: fopen(http://www.google.fr) [function.fopen]: failed to open stream: No error in C:\wamp\www\hotelGlobe\hotels_list4.php on line 4
_______________________________________________________________
P.S: I've tried with PHP4 and PHP5 but in vain.Same result with file_get_contents().
Please advise.
Thx in advance!
I'm trying to parse XML files.
WEIRD...fopen couldn't open any http file while it's working fine with any local file.
I've tried the following:
________________________________________________________
1.
$fp = fopen("D:\Software\\test.txt","r");
while($data = fgets($fp, 400))
echo $data;
--> Result OK
2.
$fp = fopen("https://www.google.fr/?gws_rd=ssl","r");
while($data = fgets($fp, 400))
echo $data;
--> Result: Warning: fopen() [function.fopen]: php_network_getaddresses: gethostbyname failed in C:\wamp\www\hotelGlobe\hotels_list4.php on line 4
Warning: fopen(http://www.google.fr) [function.fopen]: failed to open stream: No error in C:\wamp\www\hotelGlobe\hotels_list4.php on line 4
_______________________________________________________________
P.S: I've tried with PHP4 and PHP5 but in vain.Same result with file_get_contents().
Please advise.
Thx in advance!
A voir également:
- PHP: FOPEN issue
- Easy php - Télécharger - Divers Web & Internet
- Expert php pinterest - Télécharger - Langages
- Retour a la ligne php - Forum Webmastering
- Alert php - Forum PHP
- Retour a la ligne php ✓ - Forum PHP
3 réponses
Hi,
With php5, you don't need to use fopen. You can directly parse your xml file with the function simplexml_load_file.
And it works fine !
https://www.php.net/manual/en/function.simplexml-load-file.php
If you want to do that with php4, you have to change something in the php.ini:
allow_url_fopen = 1
Enjoy !
With php5, you don't need to use fopen. You can directly parse your xml file with the function simplexml_load_file.
And it works fine !
https://www.php.net/manual/en/function.simplexml-load-file.php
If you want to do that with php4, you have to change something in the php.ini:
allow_url_fopen = 1
Enjoy !
thanks for ur swift reply.
I've checked php.ini on both PHP4 and PHP5 and found out that allow_url_fopen = On.
WEIRD...Any clues?
BRs,