Retreving Title of a page

using php how to retreive the title of a page
qader99Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

us111Commented:
I think you can't do that
hmm..

you can find the title by reading the htmlfile and catch your title
by spliting <title> and </title>

0
qader99Author Commented:
can't clearly undestand what do you mean to say

please help with an example.
0
us111Commented:
Below a piece of code which gives you a title of a page
I don't think if it's the best solution but it works
You may optimize this function.....

<?
  // Open file
   $f = fopen("yourhtmlpage.html", "r");
   
   // read first line
   $line = fgets($f,2000);

   $found = false;
   while(!feof($f) && $found == false)
   {  
      // Put lowercase
      $myline = strtolower($line);
      if (strstr($myline,"<title>") <> false )
      {
         // Split string to get the title
         $title = split("<title>",$myline);
         $title = split("</title>", $title[1]);
         $title = $title[0];
         $found = true;
       }

       // Read next line
       $line = fgets($f,2000);
   }
   
   // Print title
   print ucfirst($title);
   fclose($f);
?>
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

qader99Author Commented:
Adjusted points to 20
0
qader99Author Commented:
Thank you very much the code is working
perfectly.

qader99
0
us111Commented:
don't forget to give me your points :))
thx
0
us111Commented:
Well
0
us111Commented:
Please could you accept my comment ? :))
0
us111Commented:
Hi qader99, could accept my comment as answer ?

Thanks you very much :))

us111.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.