Repasos Inglés

First line of code in PHP


In this example we demonstrate how the PHP code is interpreted by the server and the considerations that we must take into account.

PHP files

PHP files have the extension ".php", which indicates to the server that the expressions inside that file should be processed through the PHP interpreter.
The content of the php files must start with "" so that the interpreter can process the file correctly. It is worth mentioning that the advantage of PHP is its possibility of mixing the code written in this language with other types of content, such as HTM, CSS or JavaScript. In other articles we will make examples of this type of combination of contents.

Simple PHP example

In the following example we present a simple example of using PHP. This is the content of an "index.php" file. To indicate that the content of this file is code that must be interpreted by php, we place "" at the beginning and end of the file.

<?php  
	echo 'Hello  world'; 
?>
Verifying the result

The result of the code can be verified in a browser, which will print the message "Hello world" as shown in the image below.