我想执行一个linux命令,它返回linux中当前登录的用户.
使用jQuery和ajax,将此命令传递给PHP,它将使用exec()函数接收并执行此命令.应存储并返回该值.
返回时,jquery ajax应该将其返回到span标记的内容.
怎么能实现这一目标?
使用.load().像这样的东西:
$('#my-span-id').load('/path/to/page.php');
Run Code Online (Sandbox Code Playgroud)
<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
19435 次 |
| 最近记录: |