PHP before or embedded into HTML
Moderator: General Moderators
PHP before or embedded into HTML
Hello,
A simple design question. I'm rather new to PHP and was wondering if there was a 'best practice' for placing PHP code in a document. Is it better to start with PHP or start with HTML and then initiate php within the html?
Thanks,
Jason
A simple design question. I'm rather new to PHP and was wondering if there was a 'best practice' for placing PHP code in a document. Is it better to start with PHP or start with HTML and then initiate php within the html?
Thanks,
Jason
I'm not that familiar with templating engines other than reading a little bit on SMARTY. But if I remember correctly, the design documents are seperate from the coding documents, much like CSS? So if that's the case, putting PHP inside the <body> tag doesn't mean you're mixing coding and design aspects? Or am I just wrong
?
Thanks for the quick reply,
Jason
Thanks for the quick reply,
Jason
- daedalus__
- DevNet Resident
- Posts: 1925
- Joined: Thu Feb 09, 2006 4:52 pm
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
Learn properly the first time and you don't have to learn a second time.Daedalus- wrote:I honestly don't think that you should worry about it until you know more about PHP.
Stick to making pages that work and keep reading.
============================================================
Today's wisdom brought to you by the nice lady at the taco truck where I got my breakfast burrito.
============================================================
Programming logic is the code that tells your apps what to do. Display logic tells your pages what to show. You can mix the in PHP, but it makes it really tough later on down the road for you (or other developers) to change your design and/or presentation logic unless there is significant documentation or very sensible code-flow.
My first few apps were like that, all mixed up like speghetti and peanut butter. Then I got ahold of templating and it got better. Then I began using Template Lite (a fork of Smarty) and my apps fly and are easy to edit/maintain.
My suggestion, to reiterate was has already been stated a few times, is to develop a good practice now so as you grow in your development expertise you don't have to relearn something else later.
Thank you for all the replies. The PHP community is one of the reasons I was drawn to it in the first place, and it's great to see such support. And hopefully I'll learn it well the first time. Right now I'm reading two books, Beginning PHP and MySQL: From Novice to Professional from Apress by Jason Gilmore and Essential PHP Security from O'Reilly by Chris Shiflett. Hopefully these are good sources.
Thanks again,
Jason
Thanks again,
Jason