What is a PHP file and how to run them? Step by step (Example)

PHP is one of the most used languages currently for the design of applications and web pages. One of the reasons for its popularity is how easy it is for a user to run it. If you still don’t know how to do it, here we show you step by step.

What is PHP?

Hypertext Preprocessor o PHP is a scripting-like server-side programming language. It is used to create applications and websites.

Despite having been implemented for several years, it is even used to make elaborate websites such as online stores or mobile applications. PHP files end with the .php extension, like its name.

You may also be interested in:

What is a PHP file

How to open a PHP file?

With Notepad: To view the content of a PHP file and edit it, you can access it from text applications such as the notepad.

  • Select the .php file
  • Right click on it and choose the option To open with
  • In the list of available applications choose memo pad

Now you can see all the code on the page, and even edit it. The disadvantage of opening it with this application is that the elements of the code are not identified by color and it makes it more difficult to read.

BBEdit: If you are a native user of the iOS environment, the application that you can use to read the file is BBEdit.

  • Run the app BBEdit
  • Click on the menu File / Open
  • Select the file from the folder where it is located

NotePad ++: A free and very light application that is compatible with several programming languages. It is a plain text editor, but focused on programming, so editing the code is easier.

Paiza.IO: It is a well-known online editor and compiler. Write code in PHP directly on the platform or upload it to compile and check its operation.

How to execute a PHP file?

PHP files can be run from a web server like ISS and Apache. Another usual way to do it is through the console using command lines.

One of the applications that is usually used is Composer. It works as a dependency manager to import or export databases, clear cache or install applications.

However, the most used way is through servers. It does not have to be a paid service, there are application packages such as XAMPP used for testing locally.

how to view a PHP file


It works just like a Web server and it’s the way developers test applications before releasing them to an open environment. It is free and easy to install.

  • Download the application, it is available for Windows, Linux and OS X
  • Go through the installation process
  • Run the app for the first time and wait for the icon to change to green color
  • Verify that start all servicess like Apache and MySQL
  • Put the PHP files in the folder htdocs in the XAMPP folder on your hard drive
  • Open your browser of preference and type in the address bar localhost
  • The PHP files that you installed are shown, click on the one you want to run to test its operation


To run a file from CMD you must have a XAMPP pre-installation or WAMP. Remember to start the application services before running the file.

  • Place the .php files in the local folder of the server
  • Enter the Control Panel
  • Click on System / System and Security / Advanced System Settings
  • Press the button Environment Variables
  • Choose the variable PATH and click Edit
  • Put a semicolon (;) at the end of the path
  • Click OK and close all windows
  • Open the Run window with the shortcut command Win + R and type CMD
  • In the console window write the route and the name of the PHP file you want to run

How useful did you find this content?

Click on a star to rate!

Average score 0 / 5. Counting of votes: 0

So far, no votes. Be the first to rate this content.

I'm sorry this content was not useful for you!

Let me improve this content!

Tell me, how can I improve this content?

You may also be interested in:

Deja un comentario