Home > Article > Backend Development > How to add music playback in php

PHP plus music playback:
1. Define the mp3 file path under a disk, such as under d:/music
2. Read Get the file size
3. Set the media type of the file header
4. Read the file
Implementation code:
<?php
="d://music/";
$filesize=filesize($path.$file_name);
header("Content-type:audio/mpeg");
header("Content-length:$filesize");
readfile($paht.$file_name);
?>Recommendation:php server
The above is the detailed content of How to add music playback in php. For more information, please follow other related articles on the PHP Chinese website!