hostfreak Posted October 19, 2006 Share Posted October 19, 2006 I was wondering, if your coding and going in between php and html. Do you stick with your indent style your using within your php tags when your doing your html. For example:[code]<?phpinclude("include/session.php");if ($session->logged_in){ include("include/constants.inc"); $connection = mysql_connect("$server","$user","$password"); $db = mysql_select_db("$database", $connection); $sql = mysql_query("SELECT * FROM settings"); while ($row = mysql_fetch_array($sql)) { $title = $row["title"]; $companyname = $row["companyname"]; $adminemail = $row["adminemail"]; }?> <html> <head> <title><?php echo "$companyname - $title"; ?></title> <meta http-equiv="content-type" content="text/html; charset=utf-8" /> <style type="text/css" media="screen" name="style"> @import "style.css"; @import "print.css"; </style> </head> <body> <div id="top"> <div id="logo"> <?php echo "$companyname"; ?> </div> <div id="slogan"> <?php echo "$title"; ?> </div> </div> </body> </html><?php}else{ $ip = $_SERVER['REMOTE_ADDR']; echo "You are not authorized to view this page! An email has been dispatched to the administrators to inform them of your whereabouts!<br>"; echo "Your IP address: <b>$ip</b> , has been recorded and will be reported to the law if this happens again!";}?>[/code]Or would you indent the html differently? I usually don't tab, only 4 white spaces. But, to make things clearer in this example I used tab. I know it probably has a lot to do with personal preference, but if there is a certain standard / style for html I would like to know. Other wise I will probably continue doing the same style as with my php code. Sometimes though, if the html code goes into a lot of tags, it will look sloppy. Maybe it would be best in situations like that, to include the php from it's own file? So it doesn't have to embed into all the tags? Quote Link to comment Share on other sites More sharing options...
corbin Posted October 19, 2006 Share Posted October 19, 2006 I don't tab html; I just use lots of new lines :P. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 19, 2006 Share Posted October 19, 2006 If you want to use php within html then your need to learn css as css can provide outstanding results.saying that looking at your code looks good to me. Quote Link to comment Share on other sites More sharing options...
printf Posted October 19, 2006 Share Posted October 19, 2006 code wise, any code should follow the indenting of it's parent, but html should follow the output structure, so I would start <html> to left and not follow the PHP code logic, because to me they they are not the same, and in all reality don't belong there in the first place! Sure on a forum like this, most questions are about in and out processing logic, but it's not the best way for bigger applications where code logic should never be mixed with flush type logic, because it makes the code terrible to manage.me! Quote Link to comment Share on other sites More sharing options...
btherl Posted October 19, 2006 Share Posted October 19, 2006 This isn't really an answer to your question, but I use Smarty templates. Then the HTML and PHP are in separate files, and there is no question of how to indent the mixed code.The general rule I follow when deciding on how to indent is "Does it make the structure clear?" If it does, great. If it doesn't, try some other method of indenting. Eventually you'll hit on something which makes it look nice. You might need to change the indenting style for different pages because they have a different structure, rather than using one global rule for all pages. Quote Link to comment Share on other sites More sharing options...
redarrow Posted October 19, 2006 Share Posted October 19, 2006 In the below example the text is aligned to the center of the page within a paragraph with the color red and the text is transformed to uppercase letters and the first line of letters are indented. You can only indent the first line of text and select the px neededText Indent Examplep{color: red;align-text: center;text-transform: uppercase;text-indent:25px;} Quote Link to comment Share on other sites More sharing options...
hostfreak Posted October 19, 2006 Author Share Posted October 19, 2006 Thanks guys, all really good responses. I am familiar with css (not the best, still learning). I was just curious as to whether I should follow the same indention style when going between php and html. I think if it works without looking sloppy, I'll follow my normal indention style. Otherwise I'll probably end up making some changes to make it look good (which is like what btherl suggested). Once again, thanks. Quote Link to comment 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.