Ok I know I can do this via javascript but was wondering if I have say this
<HTML><HEAD><TITLE>Specifics of Bronica SQAi 150/4 PS </TITLE>
<?
include('producttopads.html');
and html proces开发者_如何学JAVAses php can I get the title...
Any ideas. Thanks Richard
// Create DOM from URL or file
$html = file_get_html('http://www.example.com/');
$title = $html->find('title', 0)->innertext;
http://simplehtmldom.sourceforge.net/manual.htm
The cleanest way to do it is this:
$pageTitle = "Specifics of Bronica SQAi 150/4 PS";
<HTML><HEAD><TITLE><?php echo $pageTitle; ?> </TITLE>
<?
include('producttopads.html');
Then you can access the title using the variable $pageTitle.
The other ways of doing it will require you to wait until after the page is loaded to access the title which isn't going to work for your purposes as I can tell.
looks like just this will do it ob_get_contents
Have a look at DOMDocument API. It can parse HTML or XML documents for you.
Example:
$dom = new DOMDocument;
$dom->loadHTML( "<html><title>your_title</title></html>" );
$title = $dom->getElementsByTagName( "title" );
echo $title->item(0)->nodeValue; // your_title
精彩评论