The fprintf() function writes a formatted string to a specified stream resource. Returns a formatted string formatting, using the inputs to dynamically input their values into the formatted string using a preset set of rules, specified below. You may also like How to calculate total price using keyup function in jquery or javascript and How to Price Range Slider using jQuery, CSS, Mysql and PHP.
Example
<?php
$number = 9;
$str = "Beijing";
$file = fopen("test.txt","w");
echo fprintf($file,"There are %u million bicycles in %s.",$number,$str);
?>
Output
40