Reputation: 444
I think this one is simple just explain it a bit please...
Supose I have this index.php (Don't look for script errors)
<html>
<head>
</head>
<body>
require(home.php)
</body>
</html>
And my home.php (I saw this somewhere and I am wondering, even if it is working is it wrong?) Instead of having again the normal html structure as above, you have:
<body>
some code
</body>
LEAVING OUT all the other tags.
Is this correct? Yes? No? Why?
Thank you
Edit: What if I am calling a js script in my head tag? Would the home.php inherite it?
Upvotes: 0
Views: 198
Reputation: 1641
No, this is not correct, there are quite a bit of errors, but it won't work because of the following reasons:
<?php
and ?>
tags. This way require() just won't execute;require('home.php');
is correct;<body></body>
tags in home.php with <?php ?>
tags, so that Google can't index that page (and can only do it from index.php;Apart from that you also have these markup errors:
<title></title>
tag is mandatory;Hope this helps.
Upvotes: 1
Reputation: 10369
Drop the start and end tag in home.php and it'll be ok (check http://www.php.net/manual/en/function.include.php for more information if needed)
Upvotes: 0
Reputation: 37454
Re-iterating what others are saying. It would look and behave the same (most likely), but fails semantically.
That is all.
Upvotes: 0
Reputation: 943100
It is incorrect. For every version of HTML, the body element may only be a child of the html element. It may never be a child of another body element.
Upvotes: 2
Reputation:
Yes. You are including the file, so php is litterally "putting it in between there".
BTW: you now have double body tags.
Upvotes: 0
Reputation: 30651
It probably shouldn't have the <body>
tag again, but otherwise okay.
Upvotes: 2