I have an external PHP file and would like to know if it is possible to link to an HTML file [closed]

0

I have an HTML file and were told to put the PHP code that would be used in an exter PHP file, is this possible? What would the code look like to "call" the external PHP file for the HTML file?

    
asked by anonymous 03.06.2017 / 12:52

1 answer

0

There are some functions to include files within other files.

  • require_once
  • require
  • include
  • include_one
  • What you need to do is use the php tags inside the html file and use these functions, for example:

    <body>
        ...
        <?php include_once('outro_arquivo.php'); ?>
        ...
    </body>
    

    Remember to include the path to the file you want to include, in the example above I assumed that outro_arquivo.php is in the same folder as the html file, so if you need to include the file that is in another folder as follows:

    <?php include_once('pasta/subpasta/arquivo.php');
    

    For this to work your main file will no longer be an html, because in order for the file to be compiled with php it needs the extension .php

        
    03.06.2017 / 14:10