Home  >  Article  >  Backend Development  >  初学者求教php打开路径有关问题

初学者求教php打开路径有关问题

WBOY
WBOYOriginal
2016-06-13 12:22:23876browse

菜鸟求教php打开路径问题
求教,在做留言练习时,


....

提交之后页面跳转是file:///D:/wamp/www/test_html/2.php

我想请教下如何把跳转的页面改成localhost/test_html/2.php

用notepad++快捷键打开的时候 也会是文件路径名 这个又如何改成localhost

------解决思路----------------------
你用的是sublime的话,就这样改:
Sublime Text 2<br />Sublime Text 3 都可以使用:<br /><br /><br />菜单 --> Tools --> New Pugin<br /><br /># 清掉内容, 添加如下代码<br /><br />import sublime, sublime_plugin<br />import webbrowser<br /><br />url_map = {<br />    'E:\phpStudy\WWW' : 'http://localhost',<br />}<br /><br />class OpenBrowserCommand(sublime_plugin.TextCommand):<br />    def run(self,edit):<br />        window = sublime.active_window()<br />        window.run_command('save')<br />        url = self.view.file_name()<br />        flag = False<br />        for path, domain in url_map.items():<br />            if url.startswith(path):<br />                url = url.replace(path, domain).replace('\\', '/')<br />                flag = True<br />                break<br />        if not flag:<br />            url = 'file://' + url<br />        webbrowser.open_new(url)<br /><br /><br /><br />然后保存文件, 保存的路径类似如下:<br /><br />C:\Users\XXXX\AppData\Roaming\Sublime Text 3\Packages\User\open_browser.py<br /><br />XXXX 为 Windows 7 系统用户, 该目录可以直接通过 Sublime 菜单找到<br /><br />菜单 --> Preferences --> Browse Packages 点击后打开的就是该目录<br /><br /><br /><br />注意:<br />    E:\phpStudy\WWW 请替换成你 Web 文档根目录所在路径<br /><br /><br />绑定快捷键<br /><br />菜单 --> Preferences --> Key Bindings-User<br /><br />添加如下代码<br /><br />[{ "keys": ["ctrl+b"], "command": "open_browser" }]
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn