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

Using the Text class for greater control over output - PHP Tutorial

From the course: PHP: Exporting Data to Files

Start my 1-month free trial

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…

Contents