美好的一天,
我愿意在Mysql中检索刚插入的行的id值.
我知道有mysqli_insert_id函数,但是:
我不想冒险查询最高的ID,因为有很多查询,它可能会给我错误的...
(我的id列是自动增量)
我想在php中生成一个正弦音.但构建我的wav我需要以字节为单位给出值.我不知道该怎么做:
这是我的代码:
$freqOfTone = 440;
$sampleRate = 44100;
$samplesCount = 80000;
$amplitude = 0.25 * 32768;
$w = 2 * pi() * $freqOfTone / $sampleRate;
//$dataArray = new
$text = "RIFF"
."80036"
."WAVE"
."fmt "
."16"
."1"
."1"
."44100"
."44100"
."1"
."8"
."data"
."80000";
for ($n = 0; $n < $samplesCount; $n++)
{
$text .= (int)($amplitude * sin($n * $w));
}
$myfile = fopen("sine.wav", "w") or die("Unable to open file!");
fwrite($myfile, $text);
fclose($myfile);
Run Code Online (Sandbox Code Playgroud) 所以我在 htaccess 中使用以下规则:
AddType SCHM wsc
<FilesMatch "\.(wsc)$">
ForceType SCHM
Header set Content-Disposition attachment
</FilesMatch>
Run Code Online (Sandbox Code Playgroud)
但是当我转到文件位置时它不会强制下载
我想将一个全局参数传递给a中的函数setTimeout
,但我希望该值在setTimeout
解释时保持不变:
var a=0;
setTimeout(function(){
console.log(a);
},5000,a)
a=1;
//output is 1 and should be 0
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?我已经搜索了Stack Overflow的答案,但没有找到任何答案.