Michiel
08-03-2003, 07:05 PM
Hi,
eversince I started writing classes I keep running into the same sort of problems. They all have to do with seperating code and layout. Before I used classes I just wrote php-scripts and directly printed html inside the script. Though the scripts were working fine, they weren't flexible at all!
From what I know the major advantage of classes is that they can be used very flexible, but somehow I'm not achieving this.
For example, I'm working on a stats class. The class stores data about the visitors and it can return them in an associative array (e.g. $stats["IE5"=>array("unique"=>5, "hits"=>10);). I know how I can display bar-charts out of this data. But I can't seem to figure out how I can display them, in a way that they can be easily be changed, without having to dig into the code of the class.
I have the same problem with a guestbook-class I'm making. Extracting the info from the database and putting it an array is easy. But how do I fit the data into a layout that is easy to edit. Or how can I allow multiple layouts without having to change something in the class itself?
I think it all comes down to a lack of basic knowledge of programming, for I have never had any real lessons. So I would be very happy, if you would share your secrets of flexible php-coding with me. How do you combine/ seperate php-code and layout?
I hope you understand my point and I'm looking forward to your replies!
Thanx, Michiel
eversince I started writing classes I keep running into the same sort of problems. They all have to do with seperating code and layout. Before I used classes I just wrote php-scripts and directly printed html inside the script. Though the scripts were working fine, they weren't flexible at all!
From what I know the major advantage of classes is that they can be used very flexible, but somehow I'm not achieving this.
For example, I'm working on a stats class. The class stores data about the visitors and it can return them in an associative array (e.g. $stats["IE5"=>array("unique"=>5, "hits"=>10);). I know how I can display bar-charts out of this data. But I can't seem to figure out how I can display them, in a way that they can be easily be changed, without having to dig into the code of the class.
I have the same problem with a guestbook-class I'm making. Extracting the info from the database and putting it an array is easy. But how do I fit the data into a layout that is easy to edit. Or how can I allow multiple layouts without having to change something in the class itself?
I think it all comes down to a lack of basic knowledge of programming, for I have never had any real lessons. So I would be very happy, if you would share your secrets of flexible php-coding with me. How do you combine/ seperate php-code and layout?
I hope you understand my point and I'm looking forward to your replies!
Thanx, Michiel