Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

While designing web pages using php, are there standards that should be followed? For example suppose there are two pages. First page looks like this:

<body>
<div>
<?php include 'page2.php';?>

page2.php file looks like this:

<?php print 'some text';?>
</div>
</body>

Is such designing a standard practice? Does it affect search engine results?

share|improve this question
add comment

3 Answers

You generate legal HTML that way, but I wouldn't recommend it. Putting a closing tag in a different file than the opening tag makes for poor readability and error prone design. As opposed to many other dubious designs I don't see any upside of this either, you will not be able to implement some smart trick because of this practice.

share|improve this answer
    
I believe that's just an example, generally you would use the include to pull content and then wrap it in tags. –  Josh K Dec 10 '10 at 15:23
2  
Yes, something like <body><? include ?></body> is perfectly legit. My point is just that you should match tags within the same file, you shouldn't have <body> and </body> in two different files. –  eBusiness Dec 10 '10 at 15:56
    
I totally agree with eBusiness. For a maintenance perspective, this will cost you a handful of hair. –  Pierre Dec 10 '10 at 16:10
    
Actually I often have the closing </body> and </html> tags in separate views. A head view and a footer / tail view. –  Josh K Dec 10 '10 at 17:03
    
Well, I guess that works OK, as long as it is part of a well defined structure it should be manageable. –  eBusiness Dec 10 '10 at 19:21
show 1 more comment

What matters is the response, or what gets sent to the browser / crawler. How that is done server side doesn't matter.

share|improve this answer
    
Thanks josh. but is such designing followed in standard websites? –  Sanket Raut Dec 10 '10 at 14:42
    
@Sanket: Yes, it's completely standard. Though that exact implementation might be a bit simple. –  Josh K Dec 10 '10 at 15:03
add comment

What you have there is idiomatic HTML generation

No problem with that - if you're happy to maintain it. As others have said, it is the final response that is important.

How can you check your response?

Use the Web Developer toolbar for Firefox, which will manage access to these validation sites from W3C:

  1. XHTML validator
  2. CSS validator

Ideally, you should target XHTML Strict but your requirements may vary.

And the search engine?

It won't see how you generate the response, it will only see the response. Search engines on the whole prefer to see well-formed, standards compliant XHTML simply because it's easier for them to parse. However, check out the Google web master notes for what they look for in order to promote your site to the top of the search results. (Hint: Google wants timely, relevant content that is considered to be the definitive resource as a result of others approving it).

share|improve this answer
    
Thanks buddy.. I will try these tools –  Sanket Raut Dec 11 '10 at 4:53
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.