clanstyles Posted July 5, 2007 Share Posted July 5, 2007 I want to know wht the proper way to create a site is. Why use classes when you can do like login check right therre isset($_post['submit'] ect.. Why hold data that way? Whats the proper way anyway? Thank You Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/ Share on other sites More sharing options...
sKunKbad Posted July 5, 2007 Share Posted July 5, 2007 You really don't need PHP until you have a need for server side scripting. I build my sites using standard XHTML type coding, then if I need to incorporate some PHP, I simply insert it. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290749 Share on other sites More sharing options...
pocobueno1388 Posted July 5, 2007 Share Posted July 5, 2007 This is a very broad question, so there really isn't a great answer for it. It really depends on what your doing. Classes are for when you are repeating the same code over and over again with different values, you want to use these with large projects. You definitely don't need them for a login script. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290753 Share on other sites More sharing options...
cluce Posted July 5, 2007 Share Posted July 5, 2007 it all depends. There really is no proper way. It is whatever is the most effecient way for that particular project Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290757 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 well like in a CMS what would you use a class for? Also, Like a user system, why use a class for the person? Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290760 Share on other sites More sharing options...
roopurt18 Posted July 5, 2007 Share Posted July 5, 2007 I almost never use classes for my data, I find that arrays suit my needs just fine 99% of the time. I do use classes heavily for components of the site's back end. For example, I have some of the following classes: CTemplate, CPage, CDatabase, etc. One of the nicest features of using classes is they eliminate polluting the global namespace with variables and functions. It's really difficult to learn how and why to use classes until you've worked on a large project or tried to reuse pieces of an old one. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290764 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 Whats the best way to learn? I am very intrestd. Right now i just use things like mysql_fetch_array for every peice of data I needed every time. It gets anoying if you know what I mean. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290771 Share on other sites More sharing options...
roopurt18 Posted July 5, 2007 Share Posted July 5, 2007 Whats the best way to learn? By asking specific questions and practicing. Right now i just use things like mysql_fetch_array for every peice of data I needed every time. That's almost specific. Pasting the code and asking if there's a more efficient way of doing the same thing would be even more specific. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290775 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 well like $result = mysql_query("SELECT * FROM `users`"); while($res = mysql_fetch_array($result)) { $res['username']; } Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290781 Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 Why use classes when you can do like login check right therre isset($_post['submit'] ect.. Why hold data that way? Classes allow you to hide and re-use allot of functionality behind the scenes amongst other things. This does not necessarily mean its the proper way to go every time. Really, its up to the individual and the project at hand. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290795 Share on other sites More sharing options...
clanstyles Posted July 5, 2007 Author Share Posted July 5, 2007 but in classes, lets say i sset a var name = john. That var name is ALWAYS john while the session is around? Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290809 Share on other sites More sharing options...
trq Posted July 5, 2007 Share Posted July 5, 2007 but in classes, lets say i sset a var name = john. That var name is ALWAYS john while the session is around? Not necessarily. Seriously... you need to do some reading. This is a huge topic your asking about and no one person is going to be able to explain it in a forum reply. This here might be a good place to start. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290814 Share on other sites More sharing options...
teng84 Posted July 5, 2007 Share Posted July 5, 2007 I want to know wht the proper way to create a site is. Why use classes when you can do like login check right therre isset($_post['submit'] ect.. Why hold data that way? Whats the proper way anyway? Thank You ya classes are not that important for you can have asite without a class but it make the script clean dynamic and short. for professional clean and short codes is the issue for professionals its not the question of can you do that? because they can but the question is that how can you do that? Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290834 Share on other sites More sharing options...
Yesideez Posted July 5, 2007 Share Posted July 5, 2007 I use classes in my scripts when I need to duplicate some functions I've written. Classes to handle MySQL functions are in a MySQL class, HTML classes are in a HTML class and so on. As I write more functions I added them to the relevant files and have so far built up a nice little library of handy functions. Saves me having to copy and paste code all the time. Quote Link to comment https://forums.phpfreaks.com/topic/58616-php-proper-form/#findComment-290835 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.