From the course: PHP: Exporting Data to Files

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Introducing the Base class for file downloads

Introducing the Base class for file downloads - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

Introducing the Base class for file downloads

We saw earlier in this chapter, that it takes only a few lines of code to export a data base result to a text file, or to a CSV file. Because so little code is involved, it might seem overkill to use custom classes instead. But even if you Copy and Paste all of this code into another file, you'll probably want to make some changes to it. For example, this code on line 12. It capitalizes the first letter of each column name in the database result. What if you want it to be all uppercase, or what if you don't want to include it at all? You might also want the idea of each database row to create links in your webpage. But you don't want that information to be included in the download file. That's where custom classes come in handy. The class definitions are in the SRC folder, that I've created at the top level of my testing site. You can find a copy of this folder in the exercise files for this video. Let's jut open it. It contains another folder called foundationphp. That's my domain…

Contents