why PHP Script does not run, but if it runs "phpinfo ();"?

2

I am working with a LAMP architecture, with apache2 server, php7.0 and MYSql, in ubuntu 16.04, and managed to configure the route for my development, in this case, that goes from /var/www/ to /var/www/html/midesarrollo , to prove it create a phpinfo file as follows <?php phpinfo(); ?> called Hola.php , leaving the following output:

However, when I try to access my index.html , it does not present anything to me; the index.html code is a call to three .php files, require_once("mod/Header.php"); require_once("mod/body.php"); require_once("mod/footer.php");

When I inspect the item with the browser I have the following output:

where you notice that you comment on the php script, which should not happen because php is on the server and php it works, as seen in the first image, but it fails as seen in the second image, at this moment I do not know what can happen, what I read tells me that this module may not be libapache2-mod-php7.0 , but this module will I installed with php, on the other hand I changed the ext from the .html file to .php, even though this should not be relevant. but the results were the same.

I appreciate you can help me.

    
asked by alvaroc 06.04.2018 в 02:34
source

1 answer

3

Files that will show programming logic for example of languages like PHP , need to have the same extension.

Otherwise, if you put .html , it will read your require statements as a normal text string ignoring the calls you are trying to make:

Explained the above, rename your file from index.html to index.php, the structure that should be left then inside is as follows:

<?php

require_once("mod/Header.php");
require_once("mod/body.php");
require_once("mod/footer.php");

It will also be convenient for the interpretation of the character sets that you declare the corresponding meta charset, in the file called header.php because I assume that this file has the upper part of the HTML structure as in the example next

  

The meta charset utf-8 helps prevent words with characters   specials like ñ and accents are displayed in a strange way

<!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8"><!--esta etiqueta incluyela-->
        <title>Document</title>
    </head>
    <body>

    </body>
    </html> 
    
answered by 06.04.2018 / 02:53
source