File_get_contents fonsiyon testi , Php ile veri çekme örneği

İlgili fonksiyonun çalışıp çalışmadığını  aşağıdaki şekilde test edebilirsiniz.

<?php
$site = file_get_contents("http://www.look2linux.com");
echo $site;
?>

 

ya da sadece title çekmek istiyor isek , aşağıdaki örneği kullanabiliriz.

<?php
function bul($bas, $son, $yazi)
{
@preg_match_all('/' . preg_quote($bas, '/') .
'(.*?)'. preg_quote($son, '/').'/', $yazi, $m);
return @$m[1];
}
$site = file_get_contents("http://www.look2linux.com");
$baslik = bul("<title>", "</title>", $site);
echo $baslik[0];
?>
Share Button

Yayımlandı

kategorisi

yazarı:

Yorumlar

Bir yanıt yazın

E-posta adresiniz yayınlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir

This site uses Akismet to reduce spam. Learn how your comment data is processed.