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:

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

page2.php file looks like this:

<?php print 'some text';?>

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

3 Answers 3


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.

  • I believe that's just an example, generally you would use the include to pull content and then wrap it in tags.
    – Josh K
    Commented Dec 10, 2010 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. Commented Dec 10, 2010 at 15:56
  • I totally agree with eBusiness. For a maintenance perspective, this will cost you a handful of hair.
    – Rabskatran
    Commented Dec 10, 2010 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
    Commented Dec 10, 2010 at 17:03
  • Well, I guess that works OK, as long as it is part of a well defined structure it should be manageable. Commented Dec 10, 2010 at 19:21

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

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

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).


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.