Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

include PHP in HTML

Tags:

html

php

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?

like image 678
slandau Avatar asked Nov 21 '25 03:11

slandau


1 Answers

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


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!