News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Why Does SMF Use Echo Statements To Output HTML code?

Started by motumbo, May 08, 2006, 03:08:36 PM

Previous topic - Next topic

motumbo

I was just wondering why SMF uses echo statements to output HTML code.  I am a beginner when it comes to PHP.  So maybe there are advantages to using echo statements?

I made a php page and used straight HTML and when I wanted to add some php code, I used the <?php tag.  It's a lot easier to read that way.

Just wondering...  Thanks to anyone who satisfies my curiosity!

Harzem

Using <?php ?> code when needed is a nice way to use when you need mostly a static html page. SMF uses a lot more php code, and most of the html codes are outputted only based on "if" or "for" statements. You can't use a nice "for" loop with changing variables embedded inside the html code. You would need hundreds of <?php?> codes. For example,

echo 'user '$name' has '$post_number ,' posts, the last was in '$board,' on '$date;


user <?php $name ?> has <?php $post_number ?> posts, the last was in <?php $board ?> on <?php $date ?>



can be seen as similar. But think about a for loop that counts all the users in this code, to create a list for example. If a user has no posts, you will not include the "last was in that board on that date". You can't code it using <?php?> codes easily.

Kindred

besides, if you get a text editor with parsing built in (conText, UltraEdit, EditPlus) then everything is nicely color-coded in an overall php file...   even echo statements that include html
Слaва
Украинi

Please do not PM, IM or Email me with support questions.  You will get better and faster responses in the support boards.  Thank you.

"Loki is not evil, although he is certainly not a force for good. Loki is... complicated."

motumbo

OK.  I understand a little better!  As I said, I'm pretty much beginner level with PHP.

Dannii

"Never imagine yourself not to be otherwise than what it might appear to others that what you were or might have been was not otherwise than what you had been would have appeared to them to be otherwise."

Advertisement: