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.
Importance of being GlocalOctober 25th, 2018
Join Web Spiders at Sitecore Symposium 2018!September 21st, 2018
Why Sitecore 9 = Mind-Blowing Customer Engagement? #FactsSeptember 21st, 2018
Top 7 Features of Sitecore Version 9.0.1September 20th, 2018
Sitecore Certification for Second Batch of WS Digital ExpertsNovember 12th, 2015
WS CMS Partners are All Leaders in Gartner's Magic Quadrant 2015August 20th, 2015