For advice, when doing a message practice,
....
After submission page jump is file:///D:/wamp/www/test_html/2.php
I would like to ask how to change the page to localhost/test_html/2.php
When you open with the notepad++ shortcut, it will also be the file path name and how to change it to localhost.
Reply to discussion (solution)
Your program is not running on the site, so it can only be a file protocol (file://) instead of the HTTP protocol
You want to open that form page in the form of an access page ....
You use sublime words, so change:
Sublime text 2Sublime text 3 can be used: menu---Tools--and New pugin# clear content, add the following code import Sublime, Sublime_pluginimport Webb Rowserurl_map = {' E:\phpStudy\WWW ': ' http://localhost ',}class openbrowsercommand (sublime_plugin. Textcommand): def run (self,edit): Window = Sublime.active_window () window.run_command (' save ') URL = Self.view.file_name () flag = False for path, domain in Url_map.items (): If Url.startswith (path) : url = url.replace (path, domain). replace (' \ \ ', '/') flag = True Break If not flag:url = ' file://' + URL webbrowser.open_new (URL) then save the file, save the path similar to the following: C:\Users\XXXX\AppData\Roam Ing\sublime Text 3\packages\user\open_browser.pyxxxx is a Windows 7 system user who can find menus directly from the Sublime menu-Preferences- Browse Packages Click to open the directory Note: E:\phpStudy\WWW Please replace your WEB document root directory where the path binding shortcut menu---Preferences key Bindings-user add The following code [{"Keys": ["Ctrl+b"], "command": "Open_bRowser "}]
You use sublime words, so change:
Sublime text 2Sublime text 3 can be used: menu---Tools--and New pugin# clear content, add the following code import Sublime, Sublime_pluginimport Webb Rowserurl_map = {' E:\phpStudy\WWW ': ' http://localhost ',}class openbrowsercommand (sublime_plugin. Textcommand): def run (self,edit): Window = Sublime.active_window () window.run_command (' save ') URL = Self.view.file_name () flag = False for path, domain in Url_map.items (): If Url.startswith (path) : url = url.replace (path, domain). replace (' \ \ ', '/') flag = True Break If not flag:url = ' file://' + URL webbrowser.open_new (URL) then save the file, save the path similar to the following: C:\Users\XXXX\AppData\Roam Ing\sublime Text 3\packages\user\open_browser.pyxxxx is a Windows 7 system user who can find menus directly from the Sublime menu-Preferences- Browse Packages Click to open the directory Note: E:\phpStudy\WWW Please replace your WEB document root directory where the path binding shortcut menu---Preferences key Bindings-user add The following code [{"Keys": ["Ctrl+b"], "command": "Open_bRowser "}]
I do this, but why use ctrl+b open PHP file is open with TXT, open HTML when the path or file?
You need to build the PHP runtime environment first.
can install WAMP2
First, you have to turn on your Apache service.
You use sublime words, so change:
Sublime text 2Sublime text 3 can be used: menu---Tools--and New pugin# clear content, add the following code import Sublime, Sublime_pluginimport Webb Rowserurl_map = {' E:\phpStudy\WWW ': ' http://localhost ',}class openbrowsercommand (sublime_plugin. Textcommand): def run (self,edit): Window = Sublime.active_window () window.run_command (' save ') URL = Self.view.file_name () flag = False for path, domain in Url_map.items (): If Url.startswith (path) : url = url.replace (path, domain). replace (' \ \ ', '/') flag = True Break If not flag:url = ' file://' + URL webbrowser.open_new (URL) then save the file, save the path similar to the following: C:\Users\XXXX\AppData\Roam Ing\sublime Text 3\packages\user\open_browser.pyxxxx is a Windows 7 system user who can find menus directly from the Sublime menu-Preferences- Browse Packages Click to open the directory Note: E:\phpStudy\WWW Please replace your WEB document root directory where the path binding shortcut menu---Preferences key Bindings-user add The following code [{"Keys": ["Ctrl+b"], "command": "Open_bRowser "}]
I do this, but why use ctrl+b open PHP file is open with TXT, open HTML when the path or file?
You can choose the default program sublime to open the PHP file, the second problem, I have been manually in the address bar to enter the URL, the above setting method I also follow the copy of the group file, so do not know why still open from file ... Do you try again, or do you have Wamp or Apache open?
You use sublime words, so change:
Sublime text 2Sublime text 3 can be used: menu---Tools--and New pugin# clear content, add the following code import Sublime, Sublime_pluginimport Webb Rowserurl_map = {' E:\phpStudy\WWW ': ' http://localhost ',}class openbrowsercommand (sublime_plugin. Textcommand): def run (self,edit): Window = Sublime.active_window () window.run_command (' save ') URL = Self.view.file_name () flag = False for path, domain in Url_map.items (): If Url.startswith (path) : url = url.replace (path, domain). replace (' \ \ ', '/') flag = True Break If not flag:url = ' file://' + URL webbrowser.open_new (URL) then save the file, save the path similar to the following: C:\Users\XXXX\AppData\Roam Ing\sublime Text 3\packages\user\open_browser.pyxxxx is a Windows 7 system user who can find menus directly from the Sublime menu-Preferences- Browse Packages Click to open the directory Note: E:\phpStudy\WWW Please replace your WEB document root directory where the path binding shortcut menu---Preferences key Bindings-user add The following code [{"Keys": ["Ctrl+b"], "command": "Open_bRowser "}]
I do this, but why use ctrl+b open PHP file is open with TXT, open HTML when the path or file?
You can choose the default program sublime to open the PHP file, the second problem, I have been manually in the address bar to enter the URL, the above setting method I also follow the copy of the group file, so do not know why still open from file ... Do you try again, or do you have Wamp or Apache open?
OK, but I also give up now, or think sublime too convenient, or with Notepad practiced hand, manual, or thank you
Is your code running at the address of localhost?