How to Get Lyrics from (Bing and Sing) using PHP Code

Authors: CodeToday | PHP Code | Views: 1792 | Posted: 03 AM: 10/12/2017 Starts Showing Full Song Lyrics Right In search results with more than 500,000 famous and familiar lyrics. You do not need to visit any other site because the lyrics are fully displayed by Bing Search. But how can you put lyrics on your website without having to copy and paste.

Today I will guide you how to get lyrics from bing search to your website using PHP Code.

After searching for the lyrics for "love story lyrics" we see the results as the image below from

search result get lyrics

The steps are as follows

  • Create html form: receive lyrics search data
  • Create a query path to
  • Get the data and analyze the html structure to find the lyrics
  • Show Lyrics on your website or application

Lyrics search path on

Note: When searching for lyrics, in addition to the song title you must add the suffix "Lyrics"'.urlencode($_POST['song']);


<form action="" method="post" class="form-inline">
<div class="form-group">
<input type="text" name="song" value="<?=$_POST['song']?>" size="80" class="form-control" required/>
<div class="form-group">
<button class="btn btn-info" type="submit" name="submit"><i class="glyphicon glyphicon-search"></i> Get Lyrics Now</button>

PHP Full Source Code

if(isset($_POST['submit'])) {

	$song      = trim($_POST['song']);
	echo '<h3 class = "text-primary">'.$song.'</h3>';
	$urlLyrics =  ''.urlencode($song);	
	$dataSong  = curlGet($urlLyrics);
	preg_match_all('/<p class="b_paractl">(.*?)</p>/si', $dataSong, $text);	
		foreach($text[1] as $lyrics) {
		  echo $lyrics;	

function curlGet($url){
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_HTTPGET, 1 );
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 );
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
	curl_setopt($ch, CURLOPT_FOLLOWLOCATION , 1 );
	curl_setopt($ch, CURLOPT_URL, $url );
	curl_setopt($ch, CURLOPT_REFERER, $ref );
	curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookie.txt');
	curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);     
	curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
	$data = curl_exec($ch);
	return $data;
After completing the above steps, you will get the image as below:

How to Get Lyrics from (Bing and Sing) using PHP Code

If you have any questions, please leave a message below