用 xampp 打开一个 php 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47027347/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Opening a php file with xampp
提问by BrownBoii333
I'm very new to web development and I'm trying to create a php contact form. I'm trying to launch it on a xampp development server, but I can't seem to figure out how. according to this site,I need to type localhost then some options of files should show up. Well it doesn't, the xampp dashboard just shows up, and my files are in the htdocs folder. Am I opening them wrong or whats happening, I've been stuck on this for hours?
我对网络开发很陌生,我正在尝试创建一个 php 联系表单。我试图在 xampp 开发服务器上启动它,但我似乎无法弄清楚如何。根据这个站点,我需要输入 localhost 然后应该显示一些文件选项。好吧,它没有,xampp 仪表板刚刚出现,我的文件在 htdocs 文件夹中。我打开它们错了还是发生了什么,我已经被困在这个问题上好几个小时了?
回答by acoder
First you need to start XAMPP. So, go to the drive where you install the XAMPP server. Generally, it's installed in C
drive. So, go to C:\xampp\
. And open the file xampp-control.exe
. When the controller open you need to start the Apache
and Mysql
. Then you see the green color besides Apache
and Mysql
. It means they are running or started. OK.
Now, go to C:\xampp\htdocs
and create a folder as you want. For an example you can create folder which name is hello
. Then open this folder and create a file which name is index.php
and open it in you editor write a basic code like this:
首先,您需要启动 XAMPP。因此,请转到安装 XAMPP 服务器的驱动器。通常,它安装在C
驱动器中。所以,去C:\xampp\
。并打开文件xampp-control.exe
。当控制器打开时,您需要启动Apache
和Mysql
。然后你会看到除了Apache
和之外的绿色Mysql
。这意味着它们正在运行或启动。好的。现在,根据需要转到C:\xampp\htdocs
并创建一个文件夹。例如,您可以创建名称为hello
. 然后打开这个文件夹并创建一个名称为的文件,index.php
然后在编辑器中打开它,编写如下基本代码:
<?php
echo "Hello World";
?>
<?php
echo "Hello World";
?>
Then save it. And open your browser. And go to localhost/hello
然后保存。并打开浏览器。然后去localhost/hello
hello
means the folder name you created.
Now, you will see the output. Which showing Hello World
hello
表示您创建的文件夹名称。现在,您将看到输出。哪个显示Hello World
Feel free to asking any question. Happy Coding!!
随时提出任何问题。快乐编码!!
回答by illuminarch
make sure your apache service on your XAMPP is running, if you using database, activate mysql too.
确保 XAMPP 上的 apache 服务正在运行,如果您使用数据库,也请激活 mysql。
and save your file in C:\xampp\htdocs
并将您的文件保存在 C:\xampp\htdocs
if your file index.php, you can access it as localhost/index.php
如果你的文件 index.php,你可以访问它 localhost/index.php
if you make folder inside htdocs like C:\xampp\htdocs\test
如果您在 htdocs 中创建文件夹,例如 C:\xampp\htdocs\test
you can access it as localhost/test/index.php
你可以访问它 localhost/test/index.php
回答by Piyush Sapariya
first check xampp is installed or not.
check the Apacheservice is started or not.
save your filename.php
file in "xampp/htdocs/**filename.php**"
Access your php file. localhost/filename.php
If your php file is in folder than : localhost/foldername/filename.php
首先检查xampp是否安装。检查Apache服务是否启动。将您的filename.php
文件保存在"xampp/htdocs/**filename.php**"
访问您的 php 文件中。localhost/filename.php
如果您的 php 文件位于以下文件夹中:localhost/foldername/filename.php