php命令在服务器上启动firefox?

标签 php linux debian

这是我尝试过的代码:

<!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/

相关文章:

php - 什么是 CMIString4096 以及如何提取其中的数据?

linux - 绕过 bash 中的退出代码

linux - 复制到unix中的目录时如何用空格替换文件名中的下划线

r - 在 Debian VM 上安装 Shiny 的服务器

c# - 如何在 Debian 上成功安装完整的 Mono Develop IDE?

linux - Raspberry Pi - 缺少 linux-headers 目录

php - 索引中的 Wordpress 插件样式

即使在浏览器刷新后使用 isset() 提交按钮检查,PHP 脚本仍然会被执行

PHP 如何保留链接中的所有 GET 变量?

计算克隆函数的可变参数数量