Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Proper PHP syntax and practices

$
0
0
I have been finding myself resorting back to PHP lately for back-end web development. I have been reading several books and playing around with different scripts etc.. One thing I have noticed since shying away from the simpleness of Wordpress is that PHP is not written in a consistent fashion. Some people use short tags <? ?> (which are discouraged, but I rarely see the proper tags in the code I debug)

Also I tend to see
<html>
   <head>
     <title><?php echo $title; ?></title>
     // More HTML header information
   </head>
   <body>
   <?php include('header.php');?>
   </body>
</html>



In a similar fashion - opening and closing so as not to parse the entire file. But I also know that some developers prefer to open the file: <?php and then not close it...

My question is in your opinions - what is the PROPER, or most preferred way to structure your documents. It can be quite annoying to have 7-8 echo statements, or php calls in a file - but what type of performance hit would parsing the entire document take? Do most professional developers prefer to insert the <?php tags only when necessary?

A lot of this can come down to developer preference, I am more concerned with best practices...

Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>