Task 3

(a) Upload and Display .txt File

" . htmlspecialchars($content) . ""; } ?>

(b) Artist Class File Operations

name = $name; } public function __toString() { return "Artist: " . $this->name; } } // Create array of Artist objects $artists = [ new Artist("Adele"), new Artist("Drake"), new Artist("Coldplay"), new Artist("Beyoncé"), new Artist("Ed Sheeran") ]; // Write to file $file = fopen("artists_data.txt", "w"); foreach ($artists as $artist) { fwrite($file, $artist . PHP_EOL); } fclose($file); // Read and display file content echo "

File Content:

"; $content = file("artists_data.txt"); foreach ($content as $line) { echo htmlspecialchars($line) . "
"; } // Recreate objects and display echo "

Recreated Artist Objects:

"; foreach ($content as $line) { $name = trim(str_replace("Artist: ", "", $line)); $artist = new Artist($name); echo $artist . "
"; } ?>