Aprovecha el precio especial.

Antes:$249

Currency
$209

Paga en 4 cuotas sin intereses

Paga en 4 cuotas sin intereses
Suscríbete

Termina en:

14d

21h

13m

55s

1

How to include php file into html files?

As you already know, with javascript and other lenguages in the web we need to create a special tag to link several files.js into html files. An example of this is as follows:

<scriptsrc="js/myscript.js"></script> // This is in a html file

In php we can do something like this with the reserved word include. We can use it as follow:

<html><head><title>This is a sample</title></head><body><?phpinclude"index.php";
                ?></body></html>

First, I am using a html file and embedded in it there is a php script. In this little code we have only one line of code where we are invoking a php file which content is the following:

<?php
        for($x = 0; $x <= 100; $x++){
                if($x%2 == 0){
                        echo "$x\n\t\t";
                        $x++;
                }else{
                        $x++;
                }
        }
?>

So, this is a way how we can include php files from others file either in the same carpet or in other.

The advantages of doing this are the following:

  • Our html file is cleaner
  • We can reuse code
  • Is easier and better than copying and pasting code
Escribe tu comentario
+ 2