Novice Ask PHP open path problem

Source: Internet
Author: User
Tags sublime text
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?

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.