duansha8115
2015-04-24 13:31
浏览 82
已采纳

使用PHP在服务器上编译C代码

I have this php code

<?php
 $Command = "cd /var/www/html/Codiad/workspace/workspace  2>&1; gcc HelloWorld.c; ./a.out"
 $Method1 = exec($Command);
 echo $Method1;
?>

The code works fine, it shows the output, but I want only see the output after click on a button. How can I do that remaining on the same page? To be more precise I have two buttons, one for compiling code and one for execute it.

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • duanjiao5082 2015-04-24 13:34
    已采纳

    I suggest you do it with AJAX and make 2 calls. One button clicks makes request that will compile. Other will execute the code.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题