Jump to content

File Include Error


ashishyadav26

Recommended Posts

Hi All,

 

I've been trying to follow the tutorial from http://www.w3schools.com/php/php_includes.asp but the example 2 displays the echo command on page rather then parsing the include file.

 

----------------------------------------

 

 

echo 'Home Tutorials References Examples About Us Contact Us';

 

Welcome to my home page.

 

Some text.

----------------------------------------

 

 

What could be wrong?

 

Thanks in advance.

Link to comment
Share on other sites

Hi All,

 

I've been trying to follow the tutorial from http://www.w3schools...hp_includes.asp but the example 2 displays the echo command on page rather then parsing the include file.

 

----------------------------------------

 

 

echo 'Home Tutorials References Examples About Us Contact Us';

 

Welcome to my home page.

 

Some text.

----------------------------------------

 

 

What could be wrong?

 

Thanks in advance.

 

Where are you including anything?

Link to comment
Share on other sites

Like this

 

"menu.php":

 

echo '<a href="/default.php">Home</a>

<a href="/tutorials.php">Tutorials</a>

<a href="/references.php">References</a>

<a href="/examples.php">Examples</a>

<a href="/about.php">About Us</a>

<a href="/contact.php">Contact Us</a>';

 

 

-------------------

inclde-ex.php

--

 

<html>

<body>

 

<div class="leftmenu">

<?php include 'menu.php'; ?>

</div>

 

<h1>Welcome to my home page.</h1>

<p>Some text.</p>

 

</body>

</html>

Link to comment
Share on other sites

Like this

 

"menu.php":

 

echo '<a href="/default.php">Home</a>

<a href="/tutorials.php">Tutorials</a>

<a href="/references.php">References</a>

<a href="/examples.php">Examples</a>

<a href="/about.php">About Us</a>

<a href="/contact.php">Contact Us</a>';

 

 

-------------------

inclde-ex.php

--

 

<html>

<body>

 

<div class="leftmenu">

<?php include 'menu.php'; ?>

</div>

 

<h1>Welcome to my home page.</h1>

<p>Some text.</p>

 

</body>

</html>

 

Have you tried putting PHP tags around your PHP code?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.