简体   繁体   English

如何让 php 响应获取请求?

[英]How can I get php to respond to get request?

As a preface I would like to say that I am very new to php AND to stack overflow so this is a very beginner question.作为序言,我想说我对 php 和堆栈溢出非常陌生,所以这是一个非常初学者的问题。

For some context: I am doing an ubuntu autoinstall and am following the following forum post for some extra settings I'm trying to do: https://askubuntu.com/questions/1290624/fetch-autoinstall-based-on-mac对于某些上下文:我正在执行 ubuntu 自动安装,并且正在关注以下论坛帖子以了解我正在尝试执行的一些额外设置: https://askubuntu.com/questions/1290624/fetch-autoinstall-based-on-mac

So the installer does a curl command which if understand correctly sends a GET request to the http server which will run some php code and finally return an edited file (is what is supposed to happen).因此,安装程序会执行 curl 命令,如果正确理解,该命令会向 http 服务器发送 GET 请求,该服务器将运行一些 php 代码并最终返回编辑后的文件(这是应该发生的)。 How can i get a php environment up and running to do just this?我怎样才能启动并运行 php 环境来执行此操作?

I have the apache http server running which I can use to get files with curl, I just need to know how to "catch" the get request and send back an edited file.我有 apache http 服务器正在运行,我可以使用它来获取 curl 的文件,我只需要知道如何“捕获”获取请求并发回编辑后的文件。

just create a PHP file in your webserver root directory then send your request to http://yourserver/your_php_file.php Your webserver will call the file your_php_file.php and this file will have to send back an edited file;)只需在您的网络服务器根目录中创建一个 PHP 文件,然后将您的请求发送到 http://yourserver/your_php_file.php 您的网络服务器将调用该文件 your_php_file.php 并且该文件将必须发回已编辑的文件;)

Try with a simple index.php file and navigate to it via the URL. The index.php file can be just this for starter:尝试使用一个简单的 index.php 文件并通过 URL 导航到它。对于初学者来说,index.php 文件可能只是这个:

<?php 

var_dump($_GET); 

and after you see what is $_GET (and I recommend read about it) you will figure out what to do next:)在你看到什么是 $_GET 之后(我建议阅读它)你会弄清楚下一步该做什么:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM