What is PHP and how do I use it?
In this article we describe the first steps with PHP and give examples of applications for the dynamic design of websites with PHP.
What is PHP and what does it have to do with my website?
PHP is a versatile scripting language that is executed on the server and is not under the control of the browser, such as JavaScript. You can also use PHP to query content from databases. PHP forms the basis for many dynamic websites and content management systems, such as WordPress, Joomla and Prestashop, and is often used for forums, form processing, editorial systems, guest books and search engines.
In contrast to Perl, PHP allows the script code to be embedded directly in HTML pages, thus separating design and programming. To do this, the code is placed between <?php and ?>
. PHP commands are usually terminated with a semicolon within the PHP area.
You can insert PHP code into HTML editors and then save the file with the extension ".php" so that the server recognises that it is a PHP script. You can then upload the page to the server via FTP.
The PHP community regularly develops PHP as a programming language. It provides new functions and features and closes existing security gaps. The latest PHP-Version 8.3 was released in November 2023. You can track the changes in the official changelog.
STRATO checks every new version for you and makes it available for your hosting package as soon as possible.
Support process
With each new release, an old version is removed from support. For example, version 8.0 expired in November 2023. This version will no longer be further developed by the PHP community and any security vulnerabilities discovered will no longer be closed.
PHP Extended Support
If you are using an outdated PHP version beyond the expiry date, you are still not taking any risks thanks to STRATO PHP Extended Support. We provide maintenance services for you in the form of regular security patches. This means that your websites are still protected against attacks and you can switch to the latest PHP version at your leisure by testing your website for compatibility with the new PHP version beforehand.
The PHP community explains how to migrate your project to a new PHP version on this help page: PHP migration
Select PHP version
With the PHP version set in the package, you decide which functions are made available to you from PHP and how up-to-date and secure they are. In addition to the setting in the STRATO customer login, you can also set this manually via an .htaccess file.
Example: "Hello World"
A very simple example is writing text, like "Hello World". with PHP. Its code looks like this:
<html>
<head>
<title>My first PHP Example</title>
</head>
<body>
<h1>PHP-Example:</h1>
<?php echo "Hello World"; ?>
</body>
</html>
When your viewers load the file, the desired text is shown instead of the PHP script code.
Example: "Show Date"
Another simple example is the display of the current date with PHP. The code looks like this:
<html>
<head>
<title>My second PHP example</title>
</head>
<body>
<h1>PHP-example</h1>
Today is <?php echo date("d.m.Y", time()); ?>.
</body>
</html>
When your viewers load the file, the current date is shown instead of the PHP script code.
Complex Examples
If you pay for your Internet connection by the minute, we recommend establishing a testing area on your computer. In order to do this, please install a webserver and PHP. Instructions on how to do this you can find under "Further Information".
Exception Start Page
If you wish to use a PHP page as your starting page, it is not necessary to have a file named index.html or index.htm on your webspace, as the server opens startpages in a specific order: .html, .htm, .php
Instead of index.php you can choose other file names which are defined as starting pages.
PHP Data Sheet
Please refer to the following articles to find out which basic settings and extensions are available for PHP at STRATO:
How do I change my PHP settings in my hosting package?
The following file extensions are assigned as standard:
old Versions | Assigned |
PHP 3 | |
PHP 4.1 | |
PHP 5.1.1 | |
PHP 4.4.1 |
Further Information
How can I access the database via PHP? |
How can I check the PHP and/or MySQL version? |
What should i keep in mind when uploading a script? |
What are the paths on your system? |
How to start a Perl script |