PHP Classes

File: ___case_of_use.php

Recommend this page to a friend!
  Classes of Michal Palma   CSV managing class   ___case_of_use.php   Download  
File: ___case_of_use.php
Role: Example script
Content type: text/plain
Description: Cases of use
Class: CSV managing class
Store and retrieve data from CSV files
Author: By
Last change:
Date: 18 years ago
Size: 962 bytes
 

Contents

Class file image Download
<?php
/*
* Case of use of Csv.class
* @package csv
* @date 2005-08-01
*/

require("_preload.php");

try {
   
$Csv = new Csv($filename = "test.csv", $separator = ";");
   
$csvData = $Csv->readAll();

    echo
"<table border='1'>";
    foreach(
$csvData as $row) {
        echo
"<tr>";
        foreach(
$row as $col) {
            echo
"<td>$col</td>";
        }
        echo
"</tr>";
    }
    echo
"</table>";
}
catch (
Exception $e) {
    echo
"<hr />";
    echo
"Exception code: <font style='color:blue'>". $e->getCode() ."</font>";
    echo
"<br />";
    echo
"Exception message: <font style='color:blue'>". nl2br($e->getMessage()) ."</font>";
    echo
"<br />";
    echo
"Thrown by: '". $e->getFile() ."'";
    echo
"<br />";
    echo
"on line: '". $e->getLine() ."'.";
    echo
"<br />";
    echo
"<br />";
    echo
"Stack trace:";
    echo
"<br />";
    echo
nl2br($e->getTraceAsString());
    echo
"<hr />";
}


?>