这是我尝试过的代码:
<!DOCTYPE HTML>
<html>
<style>
.red{
color: red;}
</style>
<?php
function runRobot() {
$output = shell_exec('ls -lart');
echo "<pre>$output</pre>";
//the code above works.
exec ('"/usr/www/firefox/firefox"');
//this code does nothing
}
if (isset($_GET['Link1'])) {
$value=runRobot();
}
?>
<div>
<nav>
<ul>
<li><a href="env.php?Link1=true">Link1</a> </li>
<li><a href="#">Link2</a></li>
<div class="red" id="1">
<p> <?php echo $value; ?> </p>
<p> test 1 --> <?php echo $outfile; ?> </p>
可以肯定的是,我在 php 上遗漏了一些重要的东西。
是否可以使用来自客户端的 php 在服务器上运行像 firefox 这样的应用程序?
最佳答案
您要查找的内容称为 headless browser .
Headless browsing may seem like an odd term, but it’s simply a name for a browser or browser simulation without the recognizable graphical interface. Instead of testing a site or performing common actions using familiar graphical elements, use cases are automated and tested with a command-line interface.
Headless browsers are commonly used for:
- Website and application testing
- JavaScript library testing
- JavaScript simulation and interactions
- Running one or more automated UI tests in the background
php中有一个非常好的框架可以满足您的需求,称为codeception
关于php命令在服务器上启动firefox?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58840239/