This wikiHow teaches you how to open and edit a PHP programming file on your Windows or Mac computer.

Method 1
Method 1 of 2:

Using Windows

  1. 1
    Download and install Notepad++. Notepad++ is a free, Windows-only text editor that can open PHP files. To install it, do the following:
  2. 2
    Advertisement
  3. 3
    Click File. It's in the top-left corner of the Notepad++ window. A drop-down menu will appear.
  4. 4
    Click Open…. This option is in the drop-down menu. Doing so brings up a File Explorer window.
  5. 5
    Select your PHP file. Go to the location of your PHP file, then click the PHP file to select it.
  6. 6
    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++.
  7. Advertisement
Method 2
Method 2 of 2:

Using a Mac

  1. 1
    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:
  2. 2
  3. 3
    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.
  4. 4
    Click File. It's in the top-left corner of the screen. A drop-down menu will appear.
  5. 5
    Click Open…. This is in the File drop-down menu. Doing so opens a Finder window.
  6. 6
    Select your PHP file. Go to the location in which your PHP file is stored, then click the PHP file to select it.
  7. 7
    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.
  8. Advertisement

Community Q&A

  • Question
    PHP 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 Answer
    Community Answer
    When 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.
  • Question
    Can I print a PHP file?
    Community Answer
    Community Answer
    Yes, you could just click File > Print. Or you could copy it into another text editor and print it from there.
  • Question
    Which is the best to use on a .PHP in my documents?
    Community Answer
    Community Answer
    At 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.
Advertisement

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.
    ⧼thumbs_response⧽



Advertisement

About This Article

Jack Lloyd
Written by:
wikiHow Technology Writer
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. This article has been viewed 865,099 times.
How helpful is this?
Co-authors: 25
Updated: July 28, 2022
Views: 865,099
Categories: PHP
Article SummaryX

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!

Did this summary help you?
Advertisement