Changes to the header must be made before any content is returned. Learn how output buffering can delay the return of content so that headers can be modified by PHP without worrying about accidentally returning content too soon.
- [Instructor] In this chapter, we've been discussing…headers and page redirection.…One of the important points, which has come up a few times,…is that it's essential that any changes to the headers…come before any output to the HTML.…In this movie, we'll look at that a little closer…and also learn how we can use output buffering to help us.…Let me start by giving you a metaphor for illustration.…Let's imagine that our PHP code is a faucet,…and our web server is a glass.…Every time our PHP code outputs some data,…it goes into the glass like drops of water.…
As soon as the web server receives its first drops of data,…it creates the headers for the data…and they can't be changed.…Once the PHP code is complete, the web server will take…the accumulated data and send it to the users browser.…Now, let's imagine a second example where our PHP code…goes not directly into the glass…but instead into another container.…This container is the PHP output buffer,…and it's like a measuring cup.…The output from the PHP code goes into the output buffer…
- Organizing project files
- Including and requiring files
- Working with URL parameters
- Encoding dynamic content
- Modifying headers and page redirection
- Creating forms and processing form data
- MySQL basics
- Using PHP to access database tables
- Creating, reading, updating, and deleting database records with PHP
- Validating data
- Preventing SQL injection
Skill Level Beginner
1. Start a Database-Driven Project
2. Build Web Pages with PHP
3. Headers and Redirects
4. Build Forms with PHP
5. MySQL Basics
6. Use PHP to Access MySQL
7. CRUD with PHP
8. Validate Data with PHP
9. Prevent SQL Injection
Next steps1m 8s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.