Reputation: 99
I am beginner in php, trying to make one main.php file that incldes header and footer for the start
<html>
<body>
<div class="header">
logo, navigation etc
</div>
<div class="footer">
Footer content here
</div>
</body>
</html>
<?php include "header.php"; ?>
<div class="main content">
<h1> header </h1>
<p> paragraph </p>
</div>
<?php include "footer.php"; ?>
Warning: include(header.php): failed to open stream: No such file or directory in - on line 1
Warning: include(): Failed opening 'header.php' for inclusion (include_path='.:') in - on line 1
Warning: include(footer.php): failed to open stream: No such file or directory in - on line 6
Warning: include(): Failed opening 'footer.php' for inclusion (include_path='.:') in - on line 6
all files are in the same foler and doing it on XAMPP
Upvotes: 1
Views: 2696
Reputation: 1489
If header, footer and main files are in the same directory, try this:
include dirname(__FILE__) . '/header.php';
Upvotes: 0
Reputation: 1
you should add your files in the same folder so they'll be in the same parent directory then you can use "include" to access them directly ex: in folder called Home there are 2 php files if i create a third one i could use this code "<?php include 'name of one the two other files found.php' hope its clear
Upvotes: 0
Reputation: 28194
Any file you are including must be in your include_path. Call get_include_path to see the current value.
Upvotes: 1