为 PHP 文件使用括号
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27856349/
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
Using Brackets for PHP files
提问by user3128376
I currently have wampserver running and I'm trying to do live preview of a php file using Brackets.io. However when I click live preview I'm getting
我目前正在运行 wampserver,我正在尝试使用 Brackets.io 实时预览 php 文件。但是,当我单击实时预览时,我得到了
Project settings for: Getting Started
Live preview base URL: ______________
I'm following this tutorialon running PHP scripts. My php file is in C:/wamp/wwww/php_proj1/php1.php so I've been trying to put this in my "Base URL"
我正在关注有关运行 PHP 脚本的本教程。我的 php 文件在 C:/wamp/www/php_proj1/php1.php 所以我一直试图把它放在我的“基本 URL”中
http://localhost/php_proj1/php1.php
However everytime when I type that and enter it, it just asks me for the "Live Preview Base URL" again and nothing happens. I also tried putting the URL in my 'File->Project settings' and that also didn't work. I'm just running a basic php script that echos some words.
但是,每次当我输入并输入它时,它只会再次询问我“实时预览基本 URL”,但没有任何反应。我还尝试将 URL 放在我的“文件->项目设置”中,但这也不起作用。我只是在运行一个基本的 php 脚本,它会回显一些单词。
It works when I manually type
当我手动输入时它有效
http://localhost/php_proj1/php1.php
in my Chrome URL but not when I use Bracets live preview.
在我的 Chrome URL 中,但在我使用 Bracets 实时预览时不是。
What am I missing or doing wrong? Do I need to config anything in my wampserver? I've just started learning php and using wampserver so I'm not entirely sure what I'm doing wrong.
我错过了什么或做错了什么?我需要在我的 wampserver 中配置任何东西吗?我刚刚开始学习 php 和使用 wampserver,所以我不完全确定我做错了什么。
Thanks!
谢谢!
EDIT: I'm following these 2 tutorials on doing this and it's just not working for me. tutorial 1and tutorial 2
编辑:我正在按照这两个教程进行操作,但它对我不起作用。 教程 1和教程 2
EDIT2: Found my mistake.. I did not do File->Open Folder to open the folder that I was working on... Thanks to everyone that helped me with this, I will definitely not make this mistake again. sigh
EDIT2:发现我的错误..我没有做文件->打开文件夹来打开我正在处理的文件夹......感谢所有帮助我解决这个问题的人,我绝对不会再犯这个错误。叹
采纳答案by user3128376
Found my mistake. I did not do File->Open Folder to open the folder that I was working on...
发现我的错误。我没有执行 File->Open Folder 来打开我正在处理的文件夹...
回答by RiggsFolly
The Live Preview Base Url
should be set to the same url that you would use to launch your project in a browser.
该Live Preview Base Url
应设置为相同的URL,你会用它来在浏览器中启动项目。
So if you have a project in C:/wamp/wwww/php_proj1/
you would launch that project in a browser by entering http://localhost/php_proj1/php1.php
therefore that is what Brackets is expecting to be entered into the Base Url
field minus the actual script file name.
因此,如果您有一个项目,C:/wamp/wwww/php_proj1/
您可以通过输入在浏览器中启动该项目,http://localhost/php_proj1/php1.php
因此 Brackets 期望在该Base Url
字段中输入的内容减去实际脚本文件名。
Remember the DocumentRoot of localhost is pointing to the folder C:/wamp/www/
记住 localhost 的 DocumentRoot 指向文件夹 C:/wamp/www/
So enter
所以输入
http://localhost/php_proj1/
into the dialog that requests the Base Url.
进入请求 Base Url 的对话框。
Assuming you are editing the file php1.php
at the time you clicked the Live Preview icon that is the script that will be run in the browser.
假设您php1.php
在单击实时预览图标时正在编辑文件,该图标是将在浏览器中运行的脚本。
Oh and of courseyou have to have WAMPServer and therefore Apache up and running when you do this as it is running the code through Apache so that the PHP code can be interpreted.
哦,当然,当您执行此操作时,您必须拥有 WAMPServer 并因此启动并运行 Apache,因为它通过 Apache 运行代码,以便可以解释 PHP 代码。
回答by Nadav S.
Try the same thing but with a simple HTML file.
Try launching your project with PHP's built-in server. Open a terminal/cmd window and go to the folder
php_proj1
. Now executephp -S localhost:8000
. Now set your Live preview path tohttp://localhost:8000/
. If this one does work, then there may be a problem with Wamp.
尝试同样的事情,但使用一个简单的 HTML 文件。
尝试使用 PHP 的内置服务器启动您的项目。打开终端/cmd 窗口并转到文件夹
php_proj1
. 现在执行php -S localhost:8000
。现在将您的实时预览路径设置为http://localhost:8000/
. 如果这个确实有效,那么 Wamp 可能有问题。
Now remember that no matter what, you're not supposed to contain a file in the Live Preview path, but only a folder path. When you contain it, you get to this URL: http://server/file.php/file.php
(double) and that's not exactly what you want...
现在请记住,无论如何,您都不应该在实时预览路径中包含文件,而应该只包含文件夹路径。当你包含它时,你会得到这个 URL: http://server/file.php/file.php
(double) 这不是你想要的......
If none of these work - there may be a problem with either your computer, Brackets, Chrome, or both. Try to reinstall them (Brackets first).
如果这些都不起作用 - 您的计算机、支架、Chrome 或两者都可能有问题。尝试重新安装它们(首先是括号)。
回答by kranthi117
My two cents, is the name of the project php_proj1
? If not you'll have to use http://localhost/
as your base URL.
我的两分钱,是项目的名字php_proj1
吗?如果不是,您将不得不使用http://localhost/
作为您的基本 URL。
Also (When you are using Brackets) check the content of the Chrome Network tab. F12 Developer Tools -> Network -> Filter -> Documents
另外(当您使用括号时)检查 Chrome 网络选项卡的内容。F12 开发者工具 -> 网络 -> 过滤器 -> 文档
Try to investigate the URLs, probably that'll give you some insight
尝试调查 URL,可能会给你一些见解