Classes...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Classes...

Post by Steveo31 »

Readin PHP & MySQL Web Development, and he goes through using classes for pages. Couldn't tell you really how it went, but my question is this. For pages that use the same general layout, like phpfreaks.com, would it be efficient (sp?) to use classes? Or is there another way?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I personally use a lot of classes to keep the general layout of a site.. and sub classes ... and sub sub classes.... althought there are many alternatives.. such as templating...

If you want the same layout on every page try this

template1.php
template2.php

all your contents pages.php

template1.php:

Code: Select all

<table>
<tr>
<td>
template2.php

Code: Select all

</td>
</tr>
</table>
Every other page.php

Code: Select all

<?php
include('template1.php');

echo "content here";

include('template2.php');
?>
The tables with obviously be a lot more complicated but it allows each page to have the same links, etc, etc.
This is generally frowned upon but nonetheless very efficient.
Steveo31
Forum Contributor
Posts: 416
Joined: Sun Nov 23, 2003 9:05 pm
Location: San Jose CA

Post by Steveo31 »

Wow.. that could get confusing.

So classes are "good" to use along with this method?
Post Reply