r/PHPhelp • u/Dr_philociraptor • Jul 26 '25
Basic php Help, Include Error, Pathing Issue?
Started coding in php , but I can't seem to use "include" or "require_once", really basic level stuff, syntax is correct because if I drop the file directly into the code it runs without issue, but if I try to pull a saved file I run into an error
code to call -
<?php include 'includes/footer1.php';?>code being called -
<footer> © <?php echo date('y')?></footer>
</body>
</html>Warning: include(includes/footer1.php): Failed to open stream: No such file or directory in C:\xampp\htdocs\New folder\class_objects.php on line 46
Warning: include(): Failed opening 'includes/footer1.php' for inclusion (include_path='C:\xampp\php\PEAR') in C:\xampp\htdocs\New folder\class_objects.php on line 46
both files are saved in my root folder, so what am I doing wrong here.
View all comments
Show parent comment
5
u/colshrapnel Jul 26 '25 edited Jul 26 '25
I am afraid you are mistaken, on all accounts
Not sure what you mean, but "includes" is not a reserved word and it can be used anywhere. Also, where exactly do you see it gets [mis]used?
it's no different from include 'includes/footer1.php'
Dunno where did you get it but this statement is outright wrong. included file can be a mix of php and HTML all right. So you don't have to write HTML in PHP strings.
Not sure what you mean, but when "you call incude on the page", it loads all right, and executes PHP in that file
Again, not sure where did you get it, but this statement is also wrong.