-1

Hi I know to some of you this is a very basic question but I am really struggling with it as i have just recently started using php files. I am trying to figure out why my html page wont print the desired output.

HTML page code:

<!DOCTYPE html>
<html lang="en">
  <head>
     <meta charset='utf-8' />
     <title>Test</title>
  </head>

  <body>
       <?php

          include 'pTest.php';
          print $num;
       ?>

 </body>
</html>

PHP file code:

<?php

   $num = 1;

?>

1 Answers1

1

Your server is not configured to look in .html files for PHP directives. The content between <?php and ?> will be sent to the browser instead of being executed.

Give both files a .php file extension. Make sure you load them through a web server that supports PHP.

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335