You are here: Re: Trapping file_get_contents for bad urls « PHP Programming Language « IT news, forums, messages
Re: Trapping file_get_contents for bad urls

Posted by Chung Leong on 12/10/05 19:51

In theory, you can create a stream context, then attach a callback
function to it to receive notifications:

$context = stream_context_create(array());
stream_context_set_params($context, array('notification' =>
'stream_callback'));
$f = fopen("http://www.google.com/", "rb", false, $context);

The parameters passed to the function are as followed:

function stream_callback(
$notifycode,
$severity,
$xmsg,
$xcode,
$bytes_sofar,
$bytes_max)

Notification codes are defined as such:

1 = RESOLVE
2 = CONNECT
3 = AUTH_REQUIRED
4 = MIME_TYPE_IS
5 = FILE_SIZE_IS
6 = REDIRECTED
7 = PROGRESS
8 = COMPLETED
9 = FAILURE
10 = AUTH_RESULT

Severity codes:

0 = INFO
1 = WARNING
2 = ERROR

In practice, however, the PHP stream API is somewhat of a
work-in-progress. Not everything is listed above is actually
implemented. As of PHP 4.3.6, the callback doesn't receive
notifications for the resolve stage.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация