Jump to content

[SOLVED] PHP w/ Javascript as variable -- HELP PLZ!


jmhyer123

Recommended Posts

I am working on a script at the moment and I am trying to read the title of the page (between <title> and </title> tags) I can't figure out how to do it in PHP so I was trying to use javascript since it is way easier. However I can't get it to work.

 

Heres the code:

$pagetitle = "<script language=javascript>document.title</script>";

 

I have tried chaning it (using " or ' around language=javascript) and I know that is the correct javascript because if you plug it into your brower as javascript:document.title it returns the title.

 

If anybody has figured this out before or if anybody knows how to do this (read the title) with PHP that would be great!

 

Thanks in advance!!

Jeffrey

$fh = fopen($DOCUMENT_ROOT.$PHP_SELF,"r");
$found=false;
$title="";
while(!feof($fh) && !found){
   if(preg_match("/<title>(.*)<\\\/title>/",fget($fh,4096),$matches)){
      $found=true;
      $title=$matches[1];
   }
}
fclose($fh);
if($found){
   // Here title is correct
}
else{
   // this page doesn't contain <title>
}

 

http://www.dmxzone.com/forum/topic.asp?topic_id=14764

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.