Posts

Showing posts from November, 2013

PHP Best Practise

Always use PHP standard tags i.e.  <?php ?> .  To ensure the future version support, Please use standard tags for PHP. Always follow a consistent naming standards. Always use Indent and white spaces in codes. It helps to read and understand the code. Always turn on the full error reporting for development. It will show you complete list of notices, warnings and errors. When you are sending you code to production, Please make sure that you have turn off the error reporting else problems would be visible to users.  You can turn on the error reporting by php.ini. error reporting can be enabled on runtime by error_reporting() function. Always do the client and server side validation wherever there is scope of user input. You can not trust on your users. Always put comment in your code. It will make it easy to understand to others. You should use caching mechanism for the performance of the site. Ex.- memcache Don’t do the deep nesting. It will make the code complicated. Always avoid

Output buffering in php

Output buffering is used by PHP to improve performance and to perform a few tricks. Without output buffering (the default), your HTML is sent to the browser in pieces as PHP processes through your script. With output buffering, your HTML is stored in a variable and sent to the browser as one piece at the end of your script. Advantages of output buffering: Turning on output buffering alone decreases the amount of time it takes to download and render our HTML because it’s not being sent to the browser in pieces as PHP processes the HTML. All the fancy stuff we can do with PHP strings, we can now do with our whole HTML page as one variable. If you’ve ever encountered the message “Warning: Cannot modify header information – headers already sent by (output)” while setting cookies, you’ll be happy to know that output buffering is your answer. Use Facebook to Comment on this Post Output buffering in php