How to run PHP code in Blogspot?
PHP is not supported by Blogspot platform which makes it extremely difficult to customize and implement some new latest developments, but there are still some ways through which you can add PHP code in your blog. The results are not 100%, but it is far better than not having a PHP code on your blog site. In this article, we will show you how to add PHP code in blogspot.
1. Create a PHP file
Before you can add PHP code in blogspot, you have to first create a PHP file in which you have to use all the PHP code that you would like to use. However, make sure that the file is free from errors otherwise things would not working look good. Following is the simple Hello World PHP code example, just for a basic guideline for some beginners:
echo '<p>Hello World - AllTips.Net</p>';
After creating the file with all your desired code make sure you save it in .php extension. For example, alltips_blogspot_lab.php, you can use NotePad++ for writing codes because it is the only FREE standard developing tool.
2. Hosting a PHP File
Since, blogspot does not allow you to host any kind of files like PHP, HTML or CSS. Therefore, you have to either host it on your hosting (if you have) or you can use Google Drive to host them for FREE.
You can also use Dropbox, and many other free hosting services but certainly they are not better than the features and reliability of Google Drive.
3. Adding PHP code to blogspot
After creating and hosting the PHP file, login into your Blogspot account. Once logged in, head over to the dashboard and select the blog on which you would like to add PHP Code.
Now it depends on your needs whether you want to add the PHP code in posts, pages, sidebar or footer. Just paste the following code anywhere you would like to display the PHP file.
<object width="500" height="400" type="text/html" data="alltips_blogspot_lab.php"></object>
Don’t forget to replace alltips_blogspot_lab.php with the URL of your own PHP file that you may have got while hosting it on services like Google Drive Dropbox and etc.
Congratulations: You have successfully added PHP code to blogspot. Go and check your blog to see if things are working as planned. Let us know, if you have a better way of doing this job.
We hope this tutorial has helped you in learning how to add PHP code in blogspot. Still, this is not the most accurate way because we are just using a iframe technique to include the codes. Blogspot needs to think more on making its platform friendly for the developers so that they can bring awesomeness to their blogs and websites.