there is a separate file data_loader.php and there is an html view.html, how to make the code from the first file run in the second?

  • it cannot be done if there is no special configuration on the server so that html supports php - L. Vadim
  • Give a link to the resource - N. Turshiev

3 answers 3

So, in case your html in the 'php' file

 <div> Hello World <?=$text;?></div> <div> Hello world <?php echo $text; ?> </div> 

If you have files with the extension .html you need to make sure that these files support php . write it in .htaccess

 AddType application/x-httpd-php .php .html 
  • And you could not give a link to any resource? - N. Turshiev
  • All the gud only have a problem, as a result of the script, leaving rhombs with questions? How to fix this? - N. Turshiev
  • Make sure your utf-8 file is L. Vadim
  • is the file with the .php extension supposed to be UTF-8? - N. Turshiev
 <head></head> <body class="page_bg"> Hello, today is <?php echo date('l, F jS, Y'); ?>. </body> </html> 

    With the condition that your file has a PHP (.php) extension, for example

     <div> <?php /*Тут ваш PHP код */ ?> </div> 

    If you need to connect a file, you should change the extension of your view.html to view.php and write in the place for insertion

     <?php include('data_loader.php'); ?>