PHP is an inventive language which lets you experiment with various forms of coding. You can try implementing some cool tricks to simplify and shorten your code. Let us see some:
Use echo like a function: It is normally thought that with echo you can concatenate (join) strings using period. However, you can implement echo as a function and use comma instead of periods. It is also faster. Here is a code snippet:
Make maximum use of single quotes: It is a good programming practice to use single quotes when possible in PHP as it saves time. PHP does not need to parse strings for variables if you use single quotes. Another important tip is that while referencing an array that has a string index, use single quotes.
Make use of arrays in form fields: You can create a form field and create an element in an array. You can also create dynamic arrays in a form field to implement check boxes where the user can check multiple boxes.
Buffering the output: You may happen to get some output on the console, when you do not want. Particularly if you re-use a framework or a template which has a display instruction, you might want to prevent anything from being displayed at that point of time. Here you can use the concept of output buffering. Here is a code snippet:
You can definitely figure out many more such tricks to make your code look smart and execute faster.
Click here for more details.
Sitecore Certification for Second Batch of WS Digital ExpertsMay 12th, 2010
WS CMS Partners are All Leaders in Gartner's Magic Quadrant 2015May 12th, 2010
Open Source vs Proprietary Platforms: What Works for Government2Citizen (G2C) PortalsMay 12th, 2010
Ektron + EPiServer - What Does the Merger Mean for Customers?May 12th, 2010
3 Reasons Why You Should Consider Upgrading to Ektron 9 Right Now!May 12th, 2010
Ektron 8.7 Brings Support For Cloud Computing, SharePoint And An Improved Editor To Make Your Life EasierMay 12th, 2010