How to get Title and Meta tags from URL using PHP

Today we’ll explain to you how to get Title and Meta tags from URL using PHP.

Get Meta tags using in-built function

Using the get_meta_tags() function we can extract the meta tags from the webpage. We need to pass the url in this function. This function returns the all <meta> tags until the closing </head> tag.

Let’s take an example for better understanding. Suppose we have an HTML head section as shown below.

index.html
index.php

Get Title and Meta tags using cURL

In the above function, we can only get the meta tags using the get_meta_tags() function but can’t get the <title> tag. So now we will show you how to get the title and meta tags using cURL in PHP.

That’s it for today.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *