James Musser
James Musser

Reputation: 755

How to "include" a file?

Here's the code I have in the html file to "include" the file "vmenu.php"

  <div id="apDivVistaMenus">

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

  <!-- Begin Vista-Buttons.com -->

  <!-- End Vista-Buttons.com -->

  </div>

The menus used to be between the comments below the php include request. But I save that code into the vmenu.php file, which looks like this:

<link href="../menu-files/peaceland_styles_zkkus.css" type="text/css" rel="stylesheet"/>

  <script type="text/javascript"> var vbImgPath="../menu-files/"</script>

  <script type="text/javascript" src="../menu-files/sczkkus.js"></script>

  <noscript><a href="http://vista-buttons.com">Xp Style Menu by Vista-Buttons.com v2.73</a></noscript>

What's the problem? They are both in the same directory. If I put the code from the vmenu.php back into the html file, it will load fine.

Thank you!

Upvotes: 0

Views: 275

Answers (2)

mattbasta
mattbasta

Reputation: 13709

Change your code to this:

<div id="apDivVistaMenus">
<!-- Begin Vista-Buttons.com -->
<?php include 'vmenu.php'; ?>
<!-- End Vista-Buttons.com -->
</div>

...and you'll be golden.

Upvotes: 0

Kamran
Kamran

Reputation: 111

Note that, in order for PHP includes to work, the file must be parsed by the PHP engine. By default, major web servers like Apache do not run .html files through the PHP interpreter, so you must either specify in your web server's configuration that you want to parse .html files as PHP files, or rename the .html file to a .php file.

Upvotes: 5

Related Questions