This article was co-authored by wikiHow staff writer, Jack Lloyd. Jack Lloyd is a Technology Writer and Editor for wikiHow. He has over two years of experience writing and editing technology-related articles. He is technology enthusiast and an English teacher.
The wikiHow Tech Team also followed the article's instructions and verified that they work.
This article has been viewed 922,929 times.
Learn more...
This wikiHow teaches you how to open and edit a PHP programming file on your Windows or Mac computer.
Opening a PHP File
Steps
-
Download and install Notepad++. Notepad++ is a free, Windows-only text editor that can open PHP files. To install it, do the following:
- Go to notepad-plus-plus.org/download/v7.5.8.html in your computer's web browser.
- Click the green DOWNLOAD button.
- Double-click the Notepad++ setup file.
- Follow the installation prompts.
-
Open Notepad++. If Notepad++ doesn't automatically open after you finish installing it, open Start , type in notepad++, and click Notepad++ at the top of the results.Advertisement
-
Click File. It's in the top-left corner of the Notepad++ window. A drop-down menu will appear.
-
Click Open…. This option is in the drop-down menu. Doing so brings up a File Explorer window.
-
Select your PHP file. Go to the location of your PHP file, then click the PHP file to select it.
-
Click Open. It's in the bottom-right corner of the window. This will open the PHP file in Notepad++, allowing you to view the file's code and make any necessary edits.
- If you do edit your PHP file, press Ctrl+S to save the changes before you exit Notepad++.
-
Download and install BBEdit. This free program allows you to view and edit numerous different file types, PHP included. To install it, do the following:
- Go to https://www.barebones.com/products/bbedit/ in your Mac's web browser.
- Click Free Download in the upper-right side of the page.
- Double-click the downloaded DMG file.
- Verify the software if prompted.
- Drag the BBEdit icon onto the "Applications" folder.
- Follow any on-screen prompts.
-
Open BBEdit. Type in bbedit, then double-click BBEdit in the resulting drop-down menu.
- If this is your first time opening BBEdit after installing, click Open when prompted, then click Continue to continue with the 30 day trial.
-
Click File. It's in the top-left corner of the screen. A drop-down menu will appear.
-
Click Open…. This is in the File drop-down menu. Doing so opens a Finder window.
-
Select your PHP file. Go to the location in which your PHP file is stored, then click the PHP file to select it.
-
Click Open. It's in the bottom-right corner of the window. Doing so opens the PHP file in BBEdit; you should now be able to see the PHP file's text.
- You may instead click Choose here.
- If you edit your PHP file, be sure to save it by pressing ⌘ Command+S.
Community Q&A
-
QuestionPHP file is running in xampp only when it is stored or copied in htdocs. I want to know why we aren't able to run the php files in their current locations instead of changing their directories?Community AnswerWhen you are running XAMPP, it is creating a web server which runs the file. The web server expects the files to be stored in the public directory, which is configurable, and defaults in the case of XAMPP to htdocs.
-
QuestionCan I print a PHP file?Community AnswerYes, you could just click File > Print. Or you could copy it into another text editor and print it from there.
-
QuestionWhich is the best to use on a .PHP in my documents?Community AnswerAt the very least, you want a plain text editor, as PHP will be plain text. However, PHP is a programming language, so you are better off using a proper PHP editor which will make it look easier to read and edit. There are many available, depending on your operating system and budget, but if you just want to see what the file is, notepad will do.
Tips
-
Dragging and dropping your PHP file into most web browsers (excluding Firefox) will open the PHP file's code. While the PHP file probably won't display correctly, you'll at least be able to view the file's code itself.Thanks
Warnings
- Always save a copy of your original PHP file before making any changes. Editing the code incorrectly can cause your website to stop functioning, so it's always best to have a backup.Thanks
About This Article
To open a PHP file on Windows, search online for Notepad++, which is a free text-editor, and download it to your computer. Once it’s finished downloading, double-click the setup file and follow the prompts to install it. After it’s installed, open Notepad++. Then, click "File" and "Open" and locate your PHP file from the file explorer. To open a PHP file on a Mac, search online for BBEdit and download it. Double-click the downloaded DMG file and drag the BBEdit icon to your “Applications” folder. When it’s finished copying, open the program from your applications. Then, click “File” and “Open” and select your PHP file from the finder window. For more tips, including how to print a PHP file, read on!
Reader Success Stories
-
"Variety of options to suit user level, requirement and choice."