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

What is PHP?

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

Although it has been implemented for several years, it is even used to build elaborate websites such as online stores or mobile applications. PHP files end with the extension.php, as a name.

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

How to open a PHP file?

With Notepad:  to view the contents of a PHP file and edit it, it can be accessed from text applications such as Notepad.




  • Select the file.php
  • Right click on it and choose the option Open with
  • In the list of available applications, choose the block notes 

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 makes it more difficult to read.

BBEdit: If you are a native user of the iOS environment, the application 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 it is in

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

Paiza.IO:  is a well-known online editor and compiler. Write code in PHP directly on the platform or upload it to compile and verify that it works.



How to run a PHP file?

PHP files can be executed by web servers such as ISS e Apache. Another common way to do this is through the console using command lines.


One of the most used applications is Compose. It works as a dependency manager for importing or exporting databases, clearing the cache or installing applications.

However, the most used way is via servers. It doesn't have to be a paid service, there are application packages like XAMPP which are used for local testing.

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

XAMPP

It works just like a server Web and it's how developers test applications before releasing them in 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 application for the first time and wait for the icon turn green
  • Check that All the services how Apache and MySQL start
  • 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 you have installed are shown, click on the one you want to run to test its operation

DCM

To run a file from CMD you need to have a previous installation of XAMPP or WAMP. Remember to start the application services before running the file.




  • Put the file.php in the server's local folder
  • Enter the control panel 
  • click on System / System and Security / Advanced System Settings 
  • Push 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 path and the name of the PHP file you want to run
add a comment of What is a PHP file and how to run them? Step by step
Comment sent successfully! We will review it in the next few hours.