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

Asked

Viewed 37 times

0

I have an HTML file and they told me to put the PHP code I would use in a PHP Exter file, is this possible? What the code would look like to "call" the external PHP file to the HTML file?

  • Have as [Edit] the question and add an example of what you want to do?

1 answer

0


Are there any functions to include files within other files.

  1. require_once
  2. require
  3. include
  4. include_one

what you need to do is use the tags php inside the archive html 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 above example I assumed the outro_arquivo.php is in the same folder as the file html, logo, if you need to include the file that is in another folder do as follows:

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

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.