Category:PHP code

From Robupixipedia
Jump to navigationJump to search

Not so long ago, I didn't like PHP because I didn't like having "code inside HTML." I preferred Perl, where the code was first, and the HTML was produced by the code. "HTML inside code"

At my job, I was basically required to use PHP, and... I have come to realize it is not actually all that bad. In fact, in several ways, it's pretty awesome.

I actually still prefer HTML inside code, but I found a way to use PHP and still have what I want..

Basically, I think this type of coding is crap:

<source lang="php"> <?php //***********************************************// // // this code is crap and formatted as such // // // fantastic description of great program // // /***********************************************/

<html> <head> </head> <body>

title

Here is a list of things for today: <?php echo "

    "; $list_of_things = array(); $list_of_things = $DB->getThings(date("Y.m.d")); foreach($list_of_things as $item) { echo "
  1. " . $item . "
  2. "; } echo "

"; ?> I love them!

</body> </html> </source>

I would see all types of things written inline, and I couldn't grok the overview of the code for anything.

I finally decided on this type of rule. For simple echo statements, such as

<source lang="php"><?php echo "echo statements"; ?></source>

I would happily code them inline. But if there was actual programming logic, I want that pulled "out"

<source lang="php"> <?php //***********************************************// // // this code is crap, but formatted nicely // // // fantastic description of great program // // /***********************************************/

<html> <head> </head> <body>

title

Here is a list of things for today: <?php echo "

    "; $list_of_things = array(); $list_of_things = $DB->getThings(date("Y.m.d")); foreach($list_of_things as $item) { echo "
  1. " . $item . "
  2. "; } echo "

";

?>

I love them!

</body> </html> </source>

For me, this makes all the difference in the readability of the code.

Subcategories

This category has only the following subcategory.

Pages in category "PHP code"

The following 2 pages are in this category, out of 2 total.