我正在寫一個代碼爲channel.htm格式並存儲在SD存儲卡中。但是當我運行channel.htm頁面。它顯示了我的PHP代碼。我不知道該怎麼辦。有人可以幫忙嗎? 我正在做有關在SD卡上運行的arduino的實驗。如何在html中運行php代碼並存儲在SD卡中?
HELP
<!DOCTYPE html>
<html>
<head>
<title>Arduino SD card Web Page</title>
</head>
<body>
<h1> Hello I am testing Arduino SD card connected to web page</h1>
<p> A web page from SD card server. </p>
<?php
$a1=array("channelOne"=>"-45",
"channelTwo"=>"-100",
"channelThree"=>"-20" );
$a2=array(
"channelOne"=>"-48",
"channelTwo"=>"-90",
"channelThree"=>"-22"
);
$diff = array_map(
function ($a1, $a2)
{
return abs($a1-$a2);
}, $a1,$a2
);
print_r($diff);
array_walk($a1,
function ($v, $k) use ($a1,$a2)
{
$v = abs($a1[$k]-$a2[$k]);
});
print_r($a1);
print_r($a2);
ob_start();
echo"<br>";echo"<br><pre>";print_r($diff);echo"</pre>";
$content = ob_get_contents();
$f = fopen("file.html", "w");
fwrite($f, $content);
fclose($f);
echo "<input type='submit' value='Write'>"
?>
</body>
</html>
下面是結果 「-45」, 「channelTwo」=> 「 - 100」, 「channelThree」=> 「 - 20」); $ a2 = array(「channelOne」=>「 - 48」,「channelTwo」=>「 - 90」,「channelThree」=>「 - 22」); $ diff = array_map(function($ a1,$ a2){return abs($ a1- $ a2);},$ a1,$ a2);的print_r($差異); array_walk($ a1,function($ v,$ k)use($ a1,$ a2){$ v = abs($ a1 [$ k] - $ a2 [$ k]);});的print_r($ A1);的print_r($ A2); ob_start();回聲 「 」;回聲「
」;的print_r($差異);回聲「
」; $ content = ob_get_contents(); $ f = fopen(「file.html」,「w」); fwrite($ f,$ content); FCLOSE($ F); echo「」/ * $ result = print_r($ diff); $ ourFileHandle = fopen(「name.txt」,'w'); FWRITE($ ourFileHandle, 「差異」); FCLOSE($ ourFileHandle); echo「Written」; *// * foreach($ a1 as $ Name => $ Temperature){echo「Channel_Name」。「 」。$ Name。「 」。「Actual_Temperature」。「 」。$ Temperature。「 「; } $ foreach($ a2 as $ Name => $ Temperature_Now){echo「Channel_Name」。「 」。$ Name。「 」。「Temperature_Now」。「 」。$ Temperature_Now。「 」 } * /?>
閱讀服務器端和客戶端語言。然後從這裏開始http://www.php.net/manual/en/intro-whatis.php –
那麼,PHP解釋器是否適用於你的小工具? –
您需要先閱讀客戶端 - 服務器技術... PHP運行在服務器中,客戶端中的html – jcho360