Programming is the basis of the digital world today. Since its inception, we have been improving and developing new languages that allow creating programs and websites that are more efficient .
It is precisely in the field of web development where more changes have occurred in what we have been of the 21st century. PHP is a programming language used to create applications that can be run from a computer or mobile application.
Files containing source code written in PHP carry the extension with the same acronym. These can contain the encoded structure of an application or part of it, being able to copy it to create another app based on the original .
Index:
What is it and what files with extension are used for. PHP?
Files with the .PHP extension are known as a feasible scripting language on the server . These are used in web development, as well as the usual programming language.
This file was created by Rasmus Lerdorf in the year of 1995 and is now installed on at least about 240 million websites . They also symbolize web pages that have codes in the programming language. These files have a code that is used to execute certain processes that are online.
The PHP engine of a web server decrypts the PHP character included in the pattern and quickly creates the HTML code from it. This character can be used by the person using the website, which is why the standard and the PHP file cannot be visible to the user.
How to open and edit .PHP files from any computer?
Although a PHP file acquires this extension by the code contained inside it, this is nothing more than a simple set of text, so any basic processor such as the Windows “Notes Blog” can read it easily .
Here we show you how to open these files in the main operating systems:
From Windows
Opening a PHP file in Windows is an extremely simple task since any text editor can both view and edit this type of file. Therefore, in this task we are going to use the «Blog of Notes» tool, which is already installed at the factory on computers with Microsoft operating system.
- What you need to do is locate the PHP file you want to view, and once this is done just right click on it.
- Among the options that will be displayed select “Open with”, which will open a window in which you must check the option “Select a program from the list of installed programs” .
- Once the program explorer opens you must click on «Blog Notes» .
Once you do all this, the program will start automatically and you can see each and every one of the codes that make up the file. To understand what is inside you need to have advanced programming knowledge with this language.
On Mac computers
You must download and install BBEdit ., which is a free program that lets you observe and edit several different formats, including PHP. If you want to install it you must do the following:
Download BBEdit 12 for Mac
Now open Spotlight . For that you must go to the icon that of the magnifying glass that is in the upper left on the screen, to do this you must type “BBEDIT” and click twice, so a drop-down menu will appear that Get out.
If this is the first time you open BBEdit after installing it, you must click on the «Open» button at the time you request it, then click on «Continue» so you can start a thirty-day trial.
Now that you are in the program, you must click on «File» in the menu bar at the top of the screen, and among the options displayed select «Open ».
Subsequently, you must go to the location where the PHP file is stored to click and choose it . Finally click on it and when you do this the PHP file is opened in BBEdit and with this you can see the text contained in it.
On Linux
To open a file in Linux you must download the VI application, although you can also use the free version VI-M that comes preinstalled. This is a text editor that helps you edit the large number of files you have.
In order to open a PHP file in your Vi editor you just have to perform the following steps:
- Place the file name. For a file called php.txt, php.txt would be placed.
- When opening this, press the «insert» key on the keyboard with the intention of enter edit mode.
- Also the «Esc» key helps you to exit edit mode, but not from editor VI.
It should be noted that the VI interface is not like that of other text editors. In this case you will have to have certain knowledge that allows you to execute each of the necessary commands to handle the tool.
How to run a .php file?
We already show you how to open it but How can these files be run? At some point you may have to run one that contains a script that can help you solve a problem. Here’s how to do it on different platforms.
In XAMPP
This is an application that helps you test several websites on your computer in case you need to load a web server online. With it you can easily execute a PHP file or several in a single stroke. What you should do is simply install the program and follow the steps below:
- Start the program. This will load in the icon tray. Click on the XAMP icon to expand the control panel.
- To continue click on the “Start” button next to “Apache” so you can start the Apache Web server. When it is running you will see that the word “Running” is highlighted next to it in green. You will also need to run « MySQL » in case your scripts require a database to work.
- The following is to place the PHP files you want to run in the folder “htdocs”, this is found within “XAMMP” on disk drive C. Files must have the extension “.php”. >
- Now what you need to do is open any of the browsers you use and enter “localhost”. A list of the files stored in the folder will automatically be opened ” htdocs » inside « XAMP ». Click on the link to a PHP file and open it to run a script .
From the terminal or CMD
Executing a file from the terminal requires a series of technical knowledge, but we will explain it in the best possible way to make it easier for you. Before you start you must configure your Windows operating system to run PHP files. To do this you must have a root program that allows PHP to run as WAMP or MAMP .
Once you have it, what you should do is the following:
- Go to the folder inside MAMP where the PHP file is stored and copy the path. This is usually affectedC:wampbinphpphp5.6.8 conseque.
- You should now go to “Control Panel” and In the “System and Security” section, we choose “System” and then in “Advanced system configuration” and then in « Environment variables ».
- Once here you must select the «PATH» variable and click on «Edit». In the second field of the variable you will get a path. To this path you must add a semicolon (;) at the end and then copy the path where the PHP file is, to end by clicking “Accept” so that the changes are saved.
>
After this you will have everything done to run PHP from the terminal, which is a bit easier than the previous one. What you should do is simply the following:
- Press the “Ctrl + R” keys to open the “Run” box in which you must type “CMD” to open the terminal.
- Once the terminal is open you must write the path in which the PHP file is saved to execute it.
List of the best applications for a document open for documents extension .Php without using NotePad ++
In addition to NotePad ++ , there are other programs where you can read documents with PHP extension without problems. Here are some of the best alternatives.
PHP Compiler
It is an instrument with which to put together a PHP plan in an .exe file . Said file would be a window application program, which can be used without using any browser. Using it requires specific technical knowledge.
PHP MySQL
This is a program that can be used easily and through which you can create several PHP pages which manage MySQL databases . In addition, it also allows you to open files already created to view their content.