PHP ПОЛУЧИТЬ TITLE СТРАНИЦЫ ПО URL

Получить title страницы по URL можно использовав функцию file_get_contents, чтобы получить содержание страницы, и регулярное выражение для поиска тега title в HTML документе.

$url = 'https://example.com';$page_content = file_get_contents($url);preg_match("/(.*)<\/title>/i", $page_content, $matches);$title = $matches[1];</code><p>В этом примере мы сохраняем URL страницы в переменную $url, получаем содержимое страницы используя file_get_contents, а затем используем preg_match для поиска содержимого тега title и сохраняем его в переменной $title.</p><!-- content_end --> <!-- c32_begin --><div style="text-align: center"><a href="/blog/go32.php" rel="nofollow" target="_blank"><img src="/blog/download32.png"></a></div><!-- c32_end --> <!-- gnezdo_top_begin --> <div id='containerId346205'></div> <script> (function(w, d, c, s, t){ w[c] = w[c] || []; w[c].push(function(){ gnezdo.create({ tizerId: 346205, containerId: 'containerId346205' }); }); })(window, document, 'gnezdoAsyncCallbacks'); </script> <!-- gnezdo_top_end --> <p>Создание одноразовых URL адресов</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/rQMfsmAWUVo' frameborder='0' allowfullscreen></iframe></div> <!-- rsya_footer_begin --> <!-- Yandex.RTB R-A-1508709-1 --> <div id="yandex_rtb_R-A-1508709-1"></div> <script>window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ renderTo: 'yandex_rtb_R-A-1508709-1', blockId: 'R-A-1508709-1' }) })</script> <!-- rsya_footer_end --> <p>How To Create A Free Website - with Free Domain \u0026 Hosting</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/XV1cOGaZUq0' frameborder='0' allowfullscreen></iframe></div> <p>Структура HTTP запроса</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/URg_Q8dclzg' frameborder='0' allowfullscreen></iframe></div> <p>Url rewriting in php - how to use url query strings in php - dynamic url in php - php tutorial - 45</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/cE3U24qSNUQ' frameborder='0' allowfullscreen></iframe></div> <p>37 php - string urlencode</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/pVkrZcgOUpA' frameborder='0' allowfullscreen></iframe></div> <p>Remove .php and ? from url for blogs website - hindi</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/1zK14nhwoes' frameborder='0' allowfullscreen></iframe></div> <p>057 Ссылки и URL (ruphp.com) Изучаем php</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/KkhKzQQo0rA' frameborder='0' allowfullscreen></iframe></div> <p>Ссылки в PHP</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/AtKspDOTNAo' frameborder='0' allowfullscreen></iframe></div> <p>How to make Dynamic Website Title Using PHP in 2 minutes</p> <div><iframe width='777' height='437' src='https://www.youtube.com/embed/TrXGNqd25Ho' frameborder='0' allowfullscreen></iframe></div> <!-- gnezdo_footer_begin --> <div id='containerId346127'></div> <script> (function(w, d, c, s, t){ w[c] = w[c] || []; w[c].push(function(){ gnezdo.create({ tizerId: 346127, containerId: 'containerId346127' }); }); })(window, document, 'gnezdoAsyncCallbacks'); </script> <!-- gnezdo_footer_end --> <div class="clear"></div> </div> <div class="clear"></div> <div class="related-posts"> <p>Рекомендуем:</p> <ul> <li class="related"><a href="https://ruphp.com/blog/php-klass-avtorizatsii.php"><img width="230" height="150" src="https://img.youtube.com/vi/3UtB4QS6EAg/mqdefault.jpg"><span class="rel-post-title">PHP КЛАСС АВТОРИЗАЦИИ</span></a></li> <li class="related"><a href="https://ruphp.com/blog/debian-ustanovka-php-56.php"><img width="230" height="150" src="https://img.youtube.com/vi/D4oDwFLtbX4/mqdefault.jpg"><span class="rel-post-title">DEBIAN УСТАНОВКА PHP 5.6</span></a></li> <li class="related"><a href="https://ruphp.com/blog/rabota-s-massivami-php.php"><img width="230" height="150" src="https://img.youtube.com/vi/Ps1s6iRWShs/mqdefault.jpg"><span class="rel-post-title">РАБОТА С МАССИВАМИ PHP</span></a></li> <li class="related"><a href="https://ruphp.com/blog/stroku-preobrazovat-v-datu-php.php"><img width="230" height="150" src="https://img.youtube.com/vi/c9MhUlTr9Mk/mqdefault.jpg"><span class="rel-post-title">СТРОКУ ПРЕОБРАЗОВАТЬ В ДАТУ PHP</span></a></li> <li class="related"><a href="https://ruphp.com/blog/php-ozhidanie-vvoda.php"><img width="230" height="150" src="https://img.youtube.com/vi/DfxuZp_7tm0/mqdefault.jpg"><span class="rel-post-title">PHP ОЖИДАНИЕ ВВОДА</span></a></li> <li class="related"><a href="https://ruphp.com/blog/telefonniy-spravochnik-php.php"><img width="230" height="150" src="https://img.youtube.com/vi/ldDQWMFJRzk/mqdefault.jpg"><span class="rel-post-title">ТЕЛЕФОННЫЙ СПРАВОЧНИК PHP</span></a></li> <li class="related"><a href="https://ruphp.com/blog/kakie-nastroyki-php-vklyuchit-na-vps.php"><img width="230" height="150" src="https://img.youtube.com/vi/Cq7ZAW92yYM/mqdefault.jpg"><span class="rel-post-title">КАКИЕ НАСТРОЙКИ PHP ВКЛЮЧИТЬ НА VPS</span></a></li> <li class="related"><a href="https://ruphp.com/blog/analiz-logov-php.php"><img width="230" height="150" src="https://img.youtube.com/vi/pAF1a_2a_6s/mqdefault.jpg"><span class="rel-post-title">АНАЛИЗ ЛОГОВ PHP</span></a></li> <li class="related"><a href="https://ruphp.com/blog/php-mysql-sborka.php"><img width="230" height="150" src="https://img.youtube.com/vi/SRPktOpHknM/mqdefault.jpg"><span class="rel-post-title">PHP MYSQL СБОРКА</span></a></li> <div class="clear"></div> </ul> </div> <div class="clear"></div> </div> </div> <div class="right-col"> <div class="side-blok"> <div class="side-title"><span>Реклама</span></div><div class="pop-content"> <!-- rsya_sidebar_begin --> <!-- Yandex.RTB R-A-1508709-2 --> <div id="yandex_rtb_R-A-1508709-2"></div> <script>window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ renderTo: 'yandex_rtb_R-A-1508709-2', blockId: 'R-A-1508709-2' }) })</script> <!-- rsya_sidebar_end --> </div> <div class="side-title"><span>Новое</span></div> <div class="pop-content"> <ul> <li> <a href="https://ruphp.com/blog/skachat-php-versii-725.php"><img width="80" height="80" src="https://img.youtube.com/vi/NtQ-6vkQRRo/default.jpg"></a> <a href="https://ruphp.com/blog/skachat-php-versii-725.php">СКАЧАТЬ PHP ВЕРСИИ 7.2.5</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   2739</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/ustanovka-php-imagick.php"><img width="80" height="80" src="https://img.youtube.com/vi/fh0YJl1dUs8/default.jpg"></a> <a href="https://ruphp.com/blog/ustanovka-php-imagick.php">УСТАНОВКА PHP IMAGICK</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   8490</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/zagruzka-fayla-cherez-php-input-oshibka-ne-rabotaet-bitriks.php"><img width="80" height="80" src="https://img.youtube.com/vi/7WCoO6QqwXM/default.jpg"></a> <a href="https://ruphp.com/blog/zagruzka-fayla-cherez-php-input-oshibka-ne-rabotaet-bitriks.php">ЗАГРУЗКА ФАЙЛА ЧЕРЕЗ PHP INPUT ОШИБКА НЕ РАБОТАЕТ БИТРИКС</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   4024</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/php-kak-v-input-postavit-tire.php"><img width="80" height="80" src="https://img.youtube.com/vi/3aWi0hc_eXg/default.jpg"></a> <a href="https://ruphp.com/blog/php-kak-v-input-postavit-tire.php">PHP КАК В INPUT ПОСТАВИТЬ ТИРЕ</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   8353</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/kak-obnovit-php-na-joomla.php"><img width="80" height="80" src="https://img.youtube.com/vi/nzKa4I8qCCE/default.jpg"></a> <a href="https://ruphp.com/blog/kak-obnovit-php-na-joomla.php">КАК ОБНОВИТЬ PHP НА JOOMLA</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   4507</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/wordpress-single-php-dlya-otdelnoy-kategorii.php"><img width="80" height="80" src="https://img.youtube.com/vi/p-mNwGXNmmQ/default.jpg"></a> <a href="https://ruphp.com/blog/wordpress-single-php-dlya-otdelnoy-kategorii.php">WORDPRESS SINGLE PHP ДЛЯ ОТДЕЛЬНОЙ КАТЕГОРИИ</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   4805</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/php-skorost-otveta-servera.php"><img width="80" height="80" src="https://img.youtube.com/vi/sbec3eGW8LU/default.jpg"></a> <a href="https://ruphp.com/blog/php-skorost-otveta-servera.php">PHP СКОРОСТЬ ОТВЕТА СЕРВЕРА</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   9252</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/primer-diagramma-razvertivaniya-veb-server-na-php.php"><img width="80" height="80" src="https://img.youtube.com/vi/ubhmZm5RuXo/default.jpg"></a> <a href="https://ruphp.com/blog/primer-diagramma-razvertivaniya-veb-server-na-php.php">ПРИМЕР ДИАГРАММА РАЗВЕРТЫВАНИЯ ВЕБ СЕРВЕР НА PHP</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   6359</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/fayl-register-php.php"><img width="80" height="80" src="https://img.youtube.com/vi/3UtB4QS6EAg/default.jpg"></a> <a href="https://ruphp.com/blog/fayl-register-php.php">ФАЙЛ REGISTER PHP</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   5271</span> <div class="clear"></div> </li> <li> <a href="https://ruphp.com/blog/ajax-i-php-kniga-skachat.php"><img width="80" height="80" src="https://img.youtube.com/vi/gJLnuO0j1ho/default.jpg"></a> <a href="https://ruphp.com/blog/ajax-i-php-kniga-skachat.php">AJAX И PHP КНИГА СКАЧАТЬ</a> <span><i class="fa fa-eye" aria-hidden="true"></i>   4031</span> <div class="clear"></div> </li> </ul> </div> <div class="side-title"><span>Реклама</span></div><div class="pop-content"> <!-- gnezdo_sidebar_begin --> <div id='containerId346206'></div> <script> (function(w, d, c, s, t){ w[c] = w[c] || []; w[c].push(function(){ gnezdo.create({ tizerId: 346206, containerId: 'containerId346206' }); }); })(window, document, 'gnezdoAsyncCallbacks'); </script> <!-- gnezdo_sidebar_end --> <!-- mailru_sidebar_begin --> <script async src="https://ad.mail.ru/static/ads-async.js"></script> <ins class="mrg-tag" style="display:inline-block;text-decoration: none;" data-ad-client="ad-983484" data-ad-slot="983484"></ins> <script>(MRGtag = window.MRGtag || []).push({})</script> <!-- mailru_sidebar_end --> </div> <div class="clear"></div> </div> </div> </div> <div class="clear"></div> </div> <div class="footer"> <div class="credits"> <p>© 2024 ruphp.com</p> <div class="foot-counter"> <!-- Yandex.Metrika counter --> <script type="text/javascript" > (function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)}; m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)}) (window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym"); ym(86763346, "init", { clickmap:true, trackLinks:true, accurateTrackBounce:true, webvisor:true }); </script> <noscript><div><img src="https://mc.yandex.ru/watch/86763346" style="position:absolute; left:-9999px;" alt="" /></div></noscript> <!-- /Yandex.Metrika counter --> </div> </div> </div> <!-- rsya_fs_begin --> <!-- Yandex.RTB R-A-1508709-3 --> <script>window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ type: 'fullscreen', blockId: 'R-A-1508709-3' }) })</script> <!-- rsya_fs_end --> <!-- rsya_floor_begin --> <!-- Yandex.RTB R-A-1508709-4 --> <script>window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ type: 'floorAd', blockId: 'R-A-1508709-4' }) })</script> <!-- rsya_floor_end --> <!-- rsya_fs_desktop_begin --> <!-- Yandex.RTB R-A-1508709-6 --> <script> window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ "blockId": "R-A-1508709-6", "type": "fullscreen", "platform": "desktop" }) }) </script> <!-- rsya_fs_desktop_end --> <!-- rsya_floor_desktop_begin --> <!-- Yandex.RTB R-A-1508709-7 --> <script> window.yaContextCb.push(()=>{ Ya.Context.AdvManager.render({ "blockId": "R-A-1508709-7", "type": "floorAd", "platform": "desktop" }) }) </script> <!-- rsya_floor_desktop_end --> <!-- mailru_popup_begin --> <script type="text/javascript"> mailru_ad_client = "ad-983223"; mailru_ad_slot = 983223; </script> <script type="text/javascript" src="https://rs.mail.ru/static/ads-min.js"></script> <!-- mailru_popup_end --> </body> </html>