PHP语法错误。添加Wordpress函数时意外$ EOF

时间:2017-05-08 16:47:35

标签: php wordpress function

将此函数添加到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');

1 个答案:

答案 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');