3

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?

1 Answer 1

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Actually, include 'main.php'; is also fine (as long as you have quotes around the filename) because include is a language construct, not a function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.