<?php/n/nfunction getWebsiteTitle(/$url) {/n /$ch = curl_init();/n curl_setopt(/$ch, CURLOPT_URL, /$url);/n curl_setopt(/$ch, CURLOPT_RETURNTRANSFER, 1);/n curl_setopt(/$ch, CURLOPT_HEADER, 0);/n /$contents = curl_exec(/$ch);/n curl_close(/$ch);/n/n preg_match('/<title>(.*)</title>/i', /$contents, /$title);/n /$title = str_replace(array(/'/r/n/', /'/r/', /'/n/', ',', ' '), '', /$title[1]);/n/n return /$title;/n}/n/n/$t_url = /'https://example.com/';/n/$title = getWebsiteTitle(/$t_url);/necho /$title;/n/n?>

使用 Curl 函数获取网站标题的 PHP 代码示例

原文地址: https://www.cveoy.top/t/topic/o7R4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录