slandau
slandau

Reputation: 95

include PHP in HTML

So I have this index.php page:

<?php 
 include main.php; 
?>

<html>
 <head>
  <link rel="stylesheet" type="text/css" href="main.css" />
  <title>MySite</title>
 </head>
 <body>
  <a id = "submit" href="submit.php">Submit</a>
  <br /> 
  <br />
  <br />
  <br />
  <br />
  <p id = "playing">Message</p>
  <?php 
   getMessage();
  ?>
 </body>
</html>

The include file main.php looks like this:

<?php
 function getMessage()
 {
  echo "Test";
 }
?>

But it is not echoing. Why?

Upvotes: 3

Views: 414

Answers (1)

user9903
user9903

Reputation:

The include function has to be called like this: include('main.php');

Upvotes: 6

Related Questions