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 - PHP Tutorial
From the course: PHP: Exporting Data to Files
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…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
(Locked)
Outputting the database result to a text file6m 32s
-
(Locked)
Outputting the result as a CSV file6m 53s
-
(Locked)
Introducing the Base class for file downloads4m 37s
-
(Locked)
Using the Text class for greater control over output7m 20s
-
(Locked)
Controlling CSV options with the Csv class6m 49s
-
(Locked)
Saving the data to a local file6m 36s
-
(Locked)
-
-
-
-
-
-