Re: Open URL with UTF8 name

[email protected] (Isaak Malik) Fri, 09 Nov 2007 17:19:34 +0100
Newsgroups php.i18n
Message-ID <[email protected]>
Luyen Tran schreef:
> Hi,
>  I try to use PHP fopen to open the URL like the
> following
> http://dir.gigablast.com/World/Català/Economia_i_empresa/Serveis/Arts_i_entreteniment.
> What i got is the error Could not open the file.
> Here is the code
>  $filename =
> "http://dir.gigablast.com/World/Català/Economia_i_empresa/Serveis/Arts_i_entreteniment";
>  fopen($filename, "r") || die ("Could not open file");
> 
> However, using IE to browse to this page is
> successful. 
> 
>  Could anyone help me with that.
> Thank alot,
>  Luyen Tran

Dear Luyen Tran,

I've just had a test and it works perfectly for me.

This is my code:

<?php
$file = 
'http://dir.gigablast.com/World/Catal%C3%A0/Economia_i_empresa/Serveis/Arts_i_entreteniment';

$r = fopen($file, 'r') or die('Cannot open file!');
$read = fread($r, 1024);
fclose($r);

print $read;
?>

Make sure that your webhost allows remote fopen connections or if it 
allows the fopen function at all.

Hope this helped.

~ Isaak Malik