Hi,
I am new to php and to this forum also. I hope I have this topic in the correct forum. I thought it might also be a candidate for PHP - Theory and Design because this is a question concerning style but as I don't really know much about PHP I guess it should be here.
I have a background in C, C++, C#, Perl, Python, but not really in PHP. The syntax appears to be similar to Perl in places. So I am trying to teach myself PHP but there is only so much one can gain from a tutorial on PHP syntax.
I have looked at the PHP code for a bulletin board (quite a well known one on the web) and was surprised to see that there are no templates. Pretty much all the template code is ejected from echo statements. I imagine if one is going to create templates that way it would render most WYSIWIG html page editors practically useless. Yet I think I have seen html templates before that allow embedding of php code in them. To complicate matters further I imagine that would make it more difficult to submit the html code to online html validators. I know I am pretty adept at creating awful html if left to my own devices.
So here is the question. What is best practice for php? Are there any? And is it considered normal to eject html from within php echo statements for all of the project templates?? Does anyone have any opinions on this?
Your insight appreciated. Thanks.
Kiwi_NZ
newbie question concerning style
Moderator: General Moderators
- social_experiment
- DevNet Master
- Posts: 2793
- Joined: Sun Feb 15, 2009 11:08 am
- Location: .za
Re: newbie question concerning style
The php code is not displayed in the html document. If you had the following php code :To complicate matters further I imagine that would make it more difficult to submit the html code to online html validators.
Code: Select all
<?php echo "<h1>Heading</h1>"; ?>Code: Select all
<h1>Heading</h1>Personally i use to create all html with php by echoing it out but recently i started combining the two, save the page as php, use html, if i have to use php code somewhere place it between php tags and it works a treat.
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering