Page 1 of 1

new to php oop programmin

Posted: Fri Sep 26, 2003 7:52 am
by harsha
hi
all

I am very new to php oop concepts and i want to dynamically generate the html pages using php classes

for that i have cr8ted few classes

such as

base class for table and td which has the variable attributes common to the both table and td such as valign,align, bgcolor,backgroung...

and the derived class table and td contains variables attribute which are unquie to them.
like that i have written classes for body, head, and other tags
and these classes also have function/methods in them for setting the value to the variables.

i that useful creating the classes for the html tags ?
and i am facing problem in implementing those classes for further coding.

i though of creating one more class called page which uses the objects of the above classes and this is where i am facing problem.

Please help me with this regard.

and i saw the news about php5 in that i read that they have removed the mysql library bundle and they have added support for sql lite.

i need to know more about sql lite is there any official site for downloading the src or bin for both (win/linux).

Posted: Fri Sep 26, 2003 11:02 am
by McGruff
CSS has overtaken layers as the preferred method of organising a layout.

http://www.w3schools.com/
http://www.glish.com/css/

A php (or any other) program can be designed in layers. You'd have a database access layer such as eclipse http://www.students.cs.uu.nl/people/voo ... /index.php, the business logic layer (which defines a bunch of vars containing the dynamic content for the page) and a presentation layer which outputs the html.

It can be a temptation to add lots of functionality to a single class but it's probably better to keep them lean & mean (the eclipse classes are a good example). Each class should do one thing well.

With lots of classes flying about in the script, you'll need to think how to combine them all together. Some good articles on patterns can be found at phppatterns.com. Some of that is hard to fathom at first - maybe start with the factory pattern.

I wouldn't add business logic (defining output vars) to classes which are responsible for presentation (your table or CSS structure). The presentation can be handled separately by including an html template which echo's out the page vars - or you can use a template engine if security is an issue. In fact, with a nicely layered program, it's easy to switch between the two. Once you've got the output vars defined you can send them anywhere you like: write to file, web page.. etc