How to Add Facebook Share Button in PHP Website?

By Hardik Savani May 14, 2024 Category : PHP

Hi Dev,

This simple article demonstrates the php Facebook share post button. We will use the Facebook share button php. I want to share with you a custom Facebook share button php. If you have a question about creating a custom Facebook share button php, I will give a simple example with a solution.

In this post, I will show you how to make a Facebook share button in php code. we will create a simple "index.php" file and add a Facebook share button. When the user clicks on that button then it opens a Facebook page and shares your given URL. so, let's see the simple example with output:


<!DOCTYPE html>



<meta charset="utf-8">

<meta name="viewport" content="width=device-width, initial-scale=1">

<title>How to Add Facebook Share Button in PHP - ItSolutionStuff.Com</title>

<link href="" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">



<div class="container">

<h2>How to Add Facebook Share Button in PHP - ItSolutionStuff.Com</h2>


$url = "";


<a href="'<?php echo $url ?>', '_blank', 'width=400,height=500');void(0);" class="btn btn-primary">Share on Facebook</i></a>





I hope it can help you...

Tags :