How to write code

This page provides an explanation about how to actually type out your code, with examples given in HTML and PHP. Of course, the idea translates well to almost any other programming or markup language. First you close an element, then you fill it's contents.

HTML

If I want this:

  • <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> <h1>My Page</h1> <p>Welcome to my page!</p> </body> </html>

Then this is how I actually type out the code:

  1. <html>

  2. <html></html>

  3. <html>↵ ↵ </html>

  4. <html> <head> </html>

  5. <html> <head></head> </html>

  6. <html> <head>↵ ↵ </head> </html>

  7. <html> <head> </head> <body></body> </html>

  8. <html> <head> </head> <body>↵ ↵ </body> </html>

  9. <html> <head> <meta /> </head> <body> </body> </html>

  10. <html> <head> <meta http-equiv="" content="" /> </head> <body> </body> </html>

  11. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> </head> <body> </body> </html>

  12. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title></title> </head> <body> </body> </html>

  13. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> </body> </html>

  14. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> <h1></h1> </body> </html>

  15. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> <h1>My Page</h1> </body> </html>

  16. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> <h1>My Page</h1> <p></p> </body> </html>

  17. <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title>My Page</title> </head> <body> <h1>My Page</h1> <p>Welcome to my page!</p> </body> </html>

PHP

If I want this:

  • <?php if ( isset($_POST["name"]) ) { echo "Nice name!"; }else{ echo "You forgot your name!"; } ?>

Then this is how I actually type out the code:

  1. <?php

  2. <?php ?>

  3. <?php↵ ↵ ?>

  4. <?php if () ?>

  5. <?php if () { } ?>

  6. <?php if () { }else{ } ?>

  7. <?php if ( isset() ) { }else{ } ?>

  8. <?php if ( isset($_POST[]) ) { }else{ } ?>

  9. <?php if ( isset($_POST[""]) ) { }else{ } ?>

  10. <?php if ( isset($_POST["name"]) ) { }else{ } ?>

  11. <?php if ( isset($_POST["name"]) ) { echo ""; }else{ } ?>

  12. <?php if ( isset($_POST["name"]) ) { echo ""; }else{ echo ""; } ?>

  13. <?php if ( isset($_POST["name"]) ) { echo "Nice name!"; }else{ echo ""; } ?>

  14. <?php if ( isset($_POST["name"]) ) { echo "Nice name!"; }else{ echo "You forgot your name!"; } ?>

Date Published: 2011-02-21



 


code, html, php, howto, tutorial An explanation about how to actually type out your code, with examples given in HTML and PHP code, html, php, howto, tutorial
[email protected] [email protected] [email protected] [email protected] [email protected]

eXTReMe Tracker