Home arrow PHP arrow Page 7 - JV’s Power Tips for PHP (1)
PHP

JV’s Power Tips for PHP (1)


In this article Justin provides some tips for improving our PHP applications such as a very simple but effective template technique.

Author Info:
By: Justin Vincent
Rating: 3 stars3 stars3 stars3 stars3 stars / 3
January 29, 2003
TABLE OF CONTENTS:
  1. · JV’s Power Tips for PHP (1)
  2. · Never Breaking Out of PHP
  3. · Basic Template Theory
  4. · Refining the Previous
  5. · Accessing Other Variables from Within this Type of Template
  6. · Using Objects to Store Multiple Output Values
  7. · Conclusion

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
JV’s Power Tips for PHP (1) - Conclusion
(Page 7 of 7 )

During the course of this article, amongst other things, we have explored why it is important to abstract programming logic from layout and display. Here are the main tips broken down into bullet points:
  • Try not to combine PHP logic and static HTML in the same place.
  • Take note of how useful the print <<<END statement is
  • Put your static HTML into PHP templates to make it very easy to merge dynamic variables into it
  • Gather dynamic variables (at the beginning of your script) and then inject them into templates (at the end of your script)
  • Make your own function such as out() and use_template() to help you
  • Use define() to make short cut aliases for use with functions like out()
  • Structure your code into directories such as functions and templates
  • Refine a function like use_template() into something more useful like get_template()
  • Use a single global object such as $output to store your dynamic output into
When I started writing this article I expected to cover a lot more ground. I haven’t even got to the reason why I mentioned turkeys. That will just have to wait until my next ‘power’ tips article. Power tips indeed. I have a website that offers amongst other things free scripts that can help to make a PHP programmers life just that little bit easier.

Anyway, thanks for your time and perhaps I’ll see you in the next instalment of JV’s Power Tips for PHP (borrowed from the name ‘Kai’s power tools for Photoshop’).

In the mean time I’m off to think about Turkeys...


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
PHP ARTICLES

- Removing Singletons in PHP
- Singletons in PHP
- Implement Facebook Javascript SDK with PHP
- Making Usage Statistics in PHP
- Installing PHP under Windows: Further Config...
- File Version Management in PHP
- Statistical View of Data in a Clustered Bar ...
- Creating a Multi-File Upload Script in PHP
- Executing Microsoft SQL Server Stored Proced...
- Code 10x More Efficiently Using Data Access ...
- A Few Tips for Speeding Up PHP Code
- The Modular Web Page
- Quick E-Commerce with PHP and PayPal
- Regression Testing With JMeter
- Building an Iterator with PHP

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 5 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials