4

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?

Josh K
  • 23,029
  • 10
  • 67
  • 100

3 Answers3

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.

aaaaaaaaaaaa
  • 1,066
1

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

Josh K
  • 23,029
  • 10
  • 67
  • 100
1

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

Gary
  • 24,440