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.
Using the Text class for greater control over output - PHP Tutorial
From the course: PHP: Exporting Data to Files
Using the Text class for greater control over output
This is cars underscore Text.php, which was created at the beginning of this chapter. We're going to replace the procedural code on lines four to seveinteen, with a text class. But before doing so, let's take a quick look at the text class definition. It's in the SRC folder, Foundationphp, Exporter. And it's Text.php. This is the class definition. We don't need to examine the code in detail, but the class declaration, on line fourteen, says it extends the Base class, which we looked at in the previous video. So it inherits the Base class's property's methods, and then builds on them. The important part, is the Constructor, so let's scroll down to find that. Here it is on line sixty two, and it takes three arguments, a database result, a file name, and an array of options. The second and third arguments, have default values, so the only required argument is the database result. If you don't supply a name for the file, download.txt is used. The options array, has four elements, local…
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)
-
-
-
-
-
-