There are times when you need to control the PHP output buffer. Shortcodes are a good example of when you want to capture the buffer and return it to WordPress instead of sending it out to the browser. In this hands-on lab, you will dive into the functionality available to you for the PHP output control.
In this hands-on lab, we’ll take a different approach to introduce you to the PHP output buffer. I’ll show you how to use it for typical use cases you’ll have in your projects:
- Adding more HTML to the content by using the
- Shortcode’s HTML
This lab comes with a companion plugin that you will install from Click here GitHub . You and I will walk through that setup process together.
What You Will Learn
- What the output buffer is
- How to turn it on
- How to get content out of the buffer and return it back
- Why you want to get the HTML out of the PHP functions and put it into a View file
- How to leverage the PHP output buffer to let you load a view file and then return it back, i.e. instead of sending it out to the browser
What You Setup to Do This lab
Make sure you have a sandbox setup on your local computer and ready to go. If you need help doing that, see this article in the Help Center.
Whoever says that coding is hard, just smack them.
Total Lab Runtime: 00:44:16
PHP Namespace gives you the means to encapsulate your code modules to improve readability and prevent code naming collisions. In this hands-on lab, you will migrate from prefixing convention to PHP namespacing. You will learn the ins and outs of namespacing.
Check out the PHP Library for more hands-on labs, insights, Docx, and more.