-4

When i try to run this script :

include('db.php');
$site=file_get_contents("https://example.com");
$baslik='#<title>(.*?)</title>#si';
$içerik='#<div class="post-content">(.*?)</div>#si';
$kategori='#<p class="post-categories"><span>Kategoriler:(.*?)</a></p>#si';

preg_match($baslik,$site,$baslikfonksiyon);
preg_match($icerik,$site,$icerikfonksiyon);
preg_match($kategori,$site,$kategorifonksiyon);

$baslikkullan=$baslikfonksiyon[1];
$icerikkullan=$icerikfonksiyon[1];
$kategorikullan=$kategorifonksiyon[1];

i see this error in error_log file :

[01-Mar-2017 20:39:41 UTC] PHP Parse error: syntax error, unexpected 'preg_match' (T_STRING) in /example/file/path on line 9

Can anyone explain to me why i get this error

Thanks.

1 Answers1

0

I think you have problem with the regex. Try with:

$baslik = '^.*?<\/title>';