将此函数添加到Wordpress函数文件时,我收到语法错误,意外$ EOF。看到什么?
function get_saturation($atts) {
<?php $sws = exec("awk -F\",\" '{if(NR==2) printf(\"\%.1f \\n\",($10/8.4)*100 )}' https://website.org/data/lastrec.csv", $retval);
echo $sws . " percent saturation<br>"; ?>
}
add_shortcode('saturation', 'get_saturation');
答案 0 :(得分:0)
你在错误的地方打开和关闭PHP标签(在函数内,即在$sws
之前)
function get_saturation($atts) {
$sws = exec("awk -F\",\" '{if(NR==2) printf(\"\%.1f \\n\",($10/8.4)*100 )}' https://website.org/data/lastrec.csv", $retval);
echo $sws . " percent saturation<br>";
}
add_shortcode('saturation', 'get_saturation');