2011-09-24 114 views
4

我想获得选项Run-> Launch With Firefox;打开我目前在Notepad ++中查看的文件,其格式为http://127.0.0.1:8080/currentfile.php,但是它只是打开到Firefox中的当前文件目录。我尝试在Notepad ++目录中编辑快捷方式xml文件,并关闭了Notepad ++并编辑了带有普通记事本的XML文件,当我启动Notepad ++备份时,它不显示我输入的设置。我如何编辑设置以加载localhost而不是Firefox中的文件目录?配置Notepad ++在localhost上运行php?

+6

只需要注意一下,你可能想要接受你问的8个问题中的一部分,如果你不这样做,你很可能不会得到答案选择一个答案。 – Steven

+3

我不认为Notepad ++可以做到这一点。在浏览器中保持打开状态并按刷新是一件麻烦的事情吗? – Ryan

+1

对不起,我对这个网站很新,我怎么接受我问的问题?只是为了将来的参考,当我问另一个问题..我欣赏btw的头,谢谢! – CLUEL3SS

回答

2

以及两件事情

  1. 你编辑了错误的文件,我猜你正在使用Windows Vista/7,真正的首选项文件位于C:\用户\用户\应用程序数据\漫游\记事本++

  2. 我不认为记事本+ +有一个只包含地址

意义的一半变量:现在使用的变量$(FULL_CURRENT_PATH)==文件:/// C:/服务器/H T docs/pages/example.php

所以你没有任何变量只包含这个页面/ example.php。

,所以我认为这是不可能

,但只要保持页面打开和编辑

+0

工作!谢谢!我记得在appdata文件夹一会儿回来,但不知道它用于这样的东西..谢谢你! – CLUEL3SS

+0

我只是想知道你用什么命令? – elibyy

+0

firefox "$(FULL_CURRENT_PATH)" to firefox " http://127.0.0.1:8080/ $(FILE_NAME )" CLUEL3SS

2

刷新后如果直接保存你的PHP文件到WAMP的www目录(无子文件夹),你可以通过执行它选择“运行...”命令并粘贴到该行:

firefox.exe "http://localhost/$(FILE_NAME)" 

这不是很好,但它会帮助你在jiffy中进行调试。

+0

对于chrome.exe和其他任何东西都是一样的,因为我敢肯定对大多数人来说都是非常明显的大家。 – Codezilla

9

下面是运行php文件的快速而脏的修复程序,即使它们位于文档根目录中的子目录中。在shortcuts.xml:

<Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 

然后在你的web服务器的根目录创建文件 “redirect.php”:

<?php 
$root = $_SERVER['DOCUMENT_ROOT']; 

$file = str_replace('\\', '/', $_GET['file']); 
$file = str_replace($root, '', $file); 

header("Location: http://localhost{$file}"); 
+0

这看起来很酷,但由于我不熟悉XML文件,也不知道如何从notepad ++ ++启动文件,所以我仍然试图找出如何实际运用它。 –

+0

这完美谢谢 –

1

我知道这是一个老问题,但:

A. Gneady的解决方案运作良好。但是,它可能需要在Windows上进行一些修改,以便在替换斜杠方向之前替换DOCUMENT_ROOT。否则,不会进行替换,并且$ file将输出与原始路径和文件名相同的输出,但反斜杠除外。

由于我在多个浏览器测试,我修改所有相关的行中 C:\用户[用户名] \应用程序数据\漫游\记事本++ \ shortcuts.xml:

<Command name="Launch in Firefox" Ctrl="yes" Alt="yes" Shift="yes" Key="88">firefox &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 
<Command name="Launch in IE" Ctrl="yes" Alt="yes" Shift="yes" Key="73">iexplore &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 
<Command name="Launch in Chrome" Ctrl="yes" Alt="yes" Shift="yes" Key="82">chrome &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 
<Command name="Launch in Safari" Ctrl="yes" Alt="yes" Shift="yes" Key="70">safari &quot;http://localhost/redirect.php?file=$(FULL_CURRENT_PATH)&quot;</Command> 

然后,创建“重定向。在Web根目录下的PHP”文件如下:

<?php 
$root = $_SERVER['DOCUMENT_ROOT']; 
$file = $_GET['file']; 
$file = str_replace($root, '', $file); 
$file = str_replace('\\', '/', $file); 

header("Location: http://localhost{$file}"); 

?> 
0

被遗忘标志/本地主机

<?php 
$root = $_SERVER['DOCUMENT_ROOT']; 
$file = $_GET['file']; 
$file = str_replace($root, '', $file); 
$file = str_replace('\\', '/', $file); 

# Was forgotten mark/

header("Location: http://localhost/{$file}"); 
?> 
0

后,这是为我工作的代码:

<?php 
$root = $_SERVER['DOCUMENT_ROOT']; 
$file = $_GET['file']; 
$file = str_replace($root, '', $file); 
$file = str_replace('\\', '/', $file); 
$file = str_replace('C:/wamp64/www/', '', $file); // Cause 'localhost' is equal to 'C:/wamp64/www/' in my case. 
header("Location: http://localhost/{$file}"); 
?> 

谢谢大家。