What do you mean by PHP

How to use PHP

Forward article
E-mail was sent successfully.
Edit article
Print preview
FAQ # 444

In this article we describe the first steps with PHP and give first application examples for the dynamic design of websites with PHP.

 

What is php
PHP is a versatile scripting language which, in contrast to Javascript, for example, is executed on the server and is therefore not under the control of the calling browser. Frequent areas of application include forums, form processing, editorial systems, guest books and search engines. Hundreds of PHP scripts are already freely available on the Internet for these and other areas of application. With PHP you also have the option of content from e.g. B. MySQL databases are comparatively easy to query and thus dynamically fill websites with content.
Another scripting language that the web likes to use for the same purpose is e.g. B. Perl. PHP differs from this, however, in its approach, because with PHP you can embed your script code in your HTML pages and you can thus largely separate design and programming from one another. As in Perl, the script code itself is executed on the server and not transferred to the browser. The browser version of the viewer is therefore not relevant.
The PHP code is simply integrated into an HTML page. To do this, the PHP code is placed between the character string. PHP commands are usually terminated with a semicolon within the PHP area.

You can of course also create your Internet pages in a graphical HTML editor and then insert the PHP code in HTML mode (if available) or in a text editor. You don't save the file with the ending ".html" but ".php" or ".php4" so that the server recognizes straight away that a PHP script has to be executed here. Then upload the Internet page with the PHP script to our server like normal Internet pages via FTP.

Example: Hello World
A very simple example is writing a text, for example "Hello World" with PHP. The code for this looks like this:

My first PHP example:

<?php Print "Hello, World!"; ?>

When you call up the file, the desired text is then displayed for your viewer instead of the PHP script code:

Another simple example is the output of the current date with PHP. The code for this looks like this:

My second PHP example:

Today is the .


When the file is called, the current date is displayed for your viewer instead of the PHP script code:

 

More complex examples
If you do not have a permanent connection to the Internet, it is advisable to set up your own test environment on your computer to test more complex PHP scripts. To do this, you need to install a web server and PHP. You can find out how to do this in the section additional Information featured websites.

Special case home page
If you want to set up a PHP page as the start page, none must index.html or index.htm are located on the web space, as the server will search your web space according to different Index startup files searched in the following order: .html, .htm, .php
The exact order can be found in the article:
Instead of index.php, you can also choose other file names which should be called up as the start page. For more information, please refer to the article:

Was this text helpful to you?