测试我的PHP脚本和表单

我有两个html表单和两个php脚本。 第一个是用于将用户电子邮件提交到.txt文件的表单,另一个是使用php代码向客户收费的Stripe支付表单。 </ p>

现在我的问题是两个php脚本存在一些问题,我无法弄清楚如何修复,因为我不确定如何测试脚本。 通常在测试html脚本时我会在我的浏览器中打开html文件,但这不适用于我的php脚本,因为该站点只显示调用/提交时脚本中写的内容。 </ p>

所以我的问题是如何测试我的脚本,而不必使用托管帐户,我甚至可以像这样测试它?</ p>
</ div>

展开原文

原文

I have two html forms and two php scripts. The first one is a form which is supposed to submit a users email to a .txt file, and the other is a Stripe payment form which uses php code to charge the customer.

Now my problem is that there are some issues with the two php scripts, that I can't figure out how to fix, because I am not really sure how to test the scripts. Normally when testing the html scripts I would just open the html files in my browser, but that doesn't work on my php scripts as the site just shows what is written in the scripts when called/submitted.

So my question is how do I test my scripts, without having to use a hosting account and can I even test it like this?

3个回答



您需要在本地计算机上运行Web服务器以进行测试。 我建议调查一下名为 Vagrant 的内容,它允许您在计算机上轻松创建虚拟机 安装任何你喜欢的东西,而不用担心弄乱别的东西。 如果你去这里,你甚至可以找到一个“盒子”来创建一个已经安装了apache和php的虚拟机。 </ p>
</ div>

展开原文

原文

You need to run a web server on your local computer to test it out. I would suggest looking into something called Vagrant, which allows you to fairly easily create virtual machines on your computer in which you can install anything you like without fear of messing up anything else. If you go here you can even find a "box" to create a virtual machine that already has apache and php installed.



根据您的PHP版本,PHP内置了一个网络服务器:</ p>

http://php.net/manual/en/features.commandline.webserver.php </ a > </ p>
</ div>

展开原文

原文

Depending on your version of PHP there's a webserver builtin right into PHP:

http://php.net/manual/en/features.commandline.webserver.php



您可能必须在启用php的情况下在本地安装Web服务器。 由于php是服务器端语言,因此需要运行服务器,以便在执行后将html发送回去。 如果您需要在浏览器上查看结果。 </ p>

http://en.wikipedia.org/ wiki / LAMP_%28software_bundle%29 。</ p>

如果您不需要在浏览器中查看结果,可以从终端运行您的脚本(必须安装php) 只是想运行你的脚本。</ p>

$ php myscript.php </ code> </ p>
</ div>

展开原文

原文

You probably have to install a web server locally with php enabled. Since php is a server side language it needs a server to run on, in order to send you back the html, after execution. If you need to see the result on a browser.

http://en.wikipedia.org/wiki/LAMP_%28software_bundle%29.

Or run your script from terminal (you must have php installed) if you don't need to see the result in the browser and just want to run your script.

$ php myscript.php

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐