PHP help

hlmaster

New Member
Messages
9
Reaction score
0
Points
0
I have the following things
index.php
Code:
<php include 'header.php'; 
?>
<php include 'footer.php'; 
?>
<php echo 'header.php'; 
?>
header.php
Code:
| <a href="/index.php">Home</a> | <a href="/interesting.php">Interesting Facts</a> |

its not displaying on my page, whats wrong?
 
Last edited:

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
you can't echo a file.

it should work. can you link me to your site?
 

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
You're not opening your tags correctly. It should be:

Code:
<?php include 'header.php'; 
?>
<?php include 'footer.php'; 
?>
<?php echo 'header.php'; 
?>

Or, much better (IMO anyway):
Code:
<?php
include 'header.php';
?>
// (Index content here)
<?php
include 'footer.php';
?>
Also, I usually see included files like this: include ('file_path'); with the parentheses, but I don't know if they're mandatory; I guess not.
 

dickey

New Member
Messages
128
Reaction score
0
Points
0
when you include a file it is the same as when you made into one file.
 

mattura

Member
Messages
570
Reaction score
2
Points
18
if you use require instead of include, any error during the 'include' will be passed over and the page will continue to load. Using include causes the whole thing to stop and break down.

After you included the 'header', you do not need to 'echo' it! This has already happened during the include.
 

Salvatos

Member
Prime Account
Messages
562
Reaction score
1
Points
18
Shouldn't require() always be preferred to include() then? And why is it not the case?
 

leafypiggy

Manager of Pens and Office Supplies
Staff member
Messages
3,819
Reaction score
163
Points
63
...

NO. require stops loading if there is an error. include passes over...
 

sycoblast

New Member
Messages
4
Reaction score
0
Points
0
include("")

Always ("") else it can subclass another file if by chance you have a similar file...

"" ensures you are looking for that class without it means there is only ONE file that is like the file you are looking for...


Like in SQL... The "*" Searches through every table to find the table you are looking for.
 
Top