我正在编写一个 channel.htm 形式的代码并存储在 sd 存储卡中。但是当我运行 channel.htm 页面时。它向我展示了 php 代码。我不知道该怎么办。有人可以帮忙吗?我正在对在 sd 卡上运行的 arduino 进行实验。
帮助
<!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($diff); array_walk($a1, 函数 ($v, $k) 使用 ($a1,$a2) { $v = abs($a1[$k]-$a2[$k]); }); print_r($a1); print_r($a2); ob_start(); 回声" ";回声"
";print_r($diff);echo"
"; $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,"diff"); fclose($ourFileHandle); echo "Written";*/ /*foreach($a1 as $Name=>$Temperature) { echo "Channel_Name"." “.$名字。” “。”Actual_Temperature“。” “.$温度。” "; } foreach($a2 as $Name=>$Temperature_Now) { echo "Channel_Name"." “.$名字。” "."Temperature_Now"." “.$Temperature_Now。” "; }*/ ?>