How can I create a PHP file

PHP is a server-side scripting language for websites. In contrast to static html pages, it enables content to be changed or saved on the server. Examples of this are a guest book, forum, comment function or the online editing and saving of data from websites. The PHP code is executed directly by the server, i.e. in the source code of the browser you cannot see what is actually behind the page. The browser always receives a finished HTML code. The current PHP version is 8.0.6.

Install local PHP server

In Windows: WAMP Server see: Wamp Server
Under Linux: Install Apache and PHP (different depending on the distribution)

PHP files are text files and are stored on the web server with the extension .php. A PHP file usually contains HTML and PHP code, switching between HTML and PHP is done by calling and ending with

If the web server is installed locally, it is called up via the web browser with: http: // localhost.
If the file is placed in the root folder of the web server and named index.php, the URL http: // localhost automatically calls http: //localhost/index.php.

to the content of the file

As already mentioned, the actual PHP code of the file begins and ends with
before and after there can be normal HTML code
e.g.

Sample video:

Create php file with installed local web server

Upload the PHP file to your provider's server


Not every provider supports PHP, especially free providers may not support PHP.

First, the file must be uploaded to the provider using an FTP program.
The file can then be interpreted by calling it up in the web browser. The URL and the name of the file are specified in the browser. If the file is named index.php, it will be selected automatically. With a local web server, "localhost", ie http: // localhost, can be used. Using the example above, you should see the following text in the browser:
Hello

This is also the control whether PHP works on your server.

If the source code appears instead of hello:, the PHP code is not interpreted, your provider has not activated PHP or cannot do PHP. Your provider may also require that the PHP files be executable:
For this you have to change the rights to execute with your FTP program
go to the html file with the FTP program and select chmod!
By default the files are set to 644, for PHP you need at least 755.