/ Published in: PHP
This function attempts to get the title of specified url, by html tag "title". The title is returned with UTF-8 encoding. If ok, returns array(true, ok, title), if an error occurs, return array(false, error, null).
Expand |
Embed | Plain Text
<?php function get_page_title($url) { while (TRUE) { $headers = @get_headers($url, TRUE); break; else $url = $headers['Location']; } : $headers['Content-Type']; $t = FALSE; $buf = ''; $tbuf = ''; { if ($c == '<') $buf = $c; elseif ($c == '>') { break; { $t = TRUE; $tbuf = ''; $buf = ''; } break; } $buf .= $c; elseif ($t) $tbuf .= $c; if ($info['timed_out']) } // hack to convert or fix utf8 encoding 'UTF-8', 'ISO-8859-1', 'ISO-8859-15', 'cp866', 'cp1251', 'cp1252', //'KOI8-R', # php bug - cannot yet handle MBCS 'BIG5', 'GB2312', 'BIG5-HKSCS', 'Shift_JIS', 'EUC-JP' } ?>
You need to login to post a comment.
