0 votes
in Programming by (300 points)

can anyone tell me how can I get meta tags in PHP? because I want to get meta title, description but i am not able to find this. I am new in PHP. Please anyone help?

1 Answer

0 votes


you can do this two ways

1-   Php built-in function   (get_meta_tags).

2 -  PHP - HTML Dom Parser using Curl.


get_meta_tags  - Extracts all meta tag content attributes from a file and returns an array.



meta tag inside head section 


<meta content="Short Tutorials" name="author">

<meta content="Short Tutorials -PHP" name="keywords">

<meta content="Short Tutorials -PHP" name="description">

<meta content="blogger" name="generator">


Only meta tags with name attributes will be parsed. Quotes are not required.

Php code 



     // in my case i want to get 4 meta tags. you can get tag which you want.


      $tags = get_meta_tags('pass url");  // pass the url


     // it will return all meta tags in array now you can get the value of meta tags which you want. 


        echo $tags['author'];         

        echo $tags['keywords'];    

        echo $tags['description']; 

        echo $tags['generator']; 



For more information check out this link. and get your solution ShortTutorials

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated