![]() |
HTML Inside the class?
Hello! I have some trouble figuring out if I should make the HTML inside of my class, of if stuff like that is done outside of the class? For some reason the code looks a lot better when you do it inside the classes, but of course they become heavy too. What do you guys do? And what would you recommend me to do? :o Thanks!
|
I recomend only using the class for handling the data. Then you have the HTML seperate(outside of the class), and feed the HTML with the data returned from the class.
|
Quote:
I hope that makes sense. |
Definetely keep it out. Just had a project some weeks ago, where all of the pagecontent was created in a class. It was such a mess, and it was almost impossible to maintain. It also kills your eyes when you need to find a certain point in that code-mess (No syntax-highlighting).
|
Objects should ONLY handle business logic whilst content should be kept to files designed to handle View logic.
|
So this looks good then..?
PHP Code:
|
Well yes.
Ideally I wouldn't use PHP to parse out layout HTML(such as forms and stuff). It's better to use some sort of template system and use regular HTML(with PHP conditionals). But that is good. At least you're not using HTML inside your class. |
Quote:
If anything got anything to add, just shoot! :D |
You've struck me with inspiration to write another article. I will be writing about basic program design, your issue will certainly fall within the usage of classes and other logic areas.
I've never been able to properly convey good program design and object uses to someone who doesn't already know it, so this may take a few days to work out. |
Can't wait Village Idiot. :D
|
I personally preffer most of the time something like this(depending wheter there is more html or php):
PHP Code:
|
Quote:
|
This article is taking me longer than I originally thought it would take. I am finding it stuff very difficult to put into words.
|
I'm beginning to think it might be better to film it as a lecture, what I'm writing just doesn't seem to be getting it though. So we might looking at a lot longer than a few days, this would take weeks. I'm wrote out an incomplete powerpoint to go with it and it is 25 slides already. This could be over an hour of me talking. Doing this would be harder, but probably be the best tutorial I've done.
|
You know how to create an atmosphere of anticipation :-) !
|
Quote:
|
We're all looking forward to your writings, Village Idiot!
|
| All times are GMT. The time now is 02:04 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0