|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2006-05-09 20:06 UTC] cherkasov_ivan at mail dot ru
Description: ------------ I can't to include or get the result of php code or html text from the Internet links. PHP is making a system misstake... W2k tells:" php.exe called misstake and will be closed. Need to restart the program. Created log of misstakes. OK" How can I correct this misstake? PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 10:00:01 2025 UTC |
Here is an example of PHP code that gives currency exchange courses on a current date. Under Win32 it does not works. On the hosting it works... <?php function get_content() { // Making current date $date = date("d/m/Y"); // Making link $link = "http://www.cbr.ru/scripts/XML_daily.asp?date_req=$date"; // Loading HTML-page $fd = fopen($link, "r"); $text=""; if (!$fd) echo "Requested page not found!"; else { // Reading file to variable $text while (!feof ($fd)) $text .= fgets($fd, 4096); } // Close file descriptor fclose ($fd); return $text; } $content = get_content(); $pattern = "#<Valute ID=\"([^\"]+)[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>([^<]+)[^>]+>[^>]+>([^<]+)#i"; preg_match_all($pattern, $content, $out, PREG_SET_ORDER); $dollar = ""; $euro = ""; foreach($out as $cur) { if($cur[2] == 840) $dollar = str_replace(",",".",$cur[4]); if($cur[2] == 978) $euro = str_replace(",",".",$cur[4]); } $date = date("d.m.Y"); echo "Currency exchange courses on ".$date."<br>"; echo "Dollar - ".$dollar."<br>"; echo "Euro - ".$euro."<br>"; ?>