Files
2026-10-06 12:10:09 +09:00

23 lines
1.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
/**
* [Ex04 カスタム例外の利用 - CSVファイル処理]
*
* 難易度:中級
*
* TODO:
* 1. 以下の仕様に従って、カスタム例外クラスを作成してください。
* (1) FileNotFoundException クラスを作成し、Exception を継承する。
* (2) CSVFormatException クラスを作成し、Exception を継承する。
*
* 2. 関数 processCSV($filename) を作成してください。
* - $filename が "data.csv" でない場合は、FileNotFoundException を投げる。
* - $filename が "data.csv" の場合、仮のCSVデータ(例: "John,25,Engineer\nAlice,30,Designer")を用い、
* 各行がカンマで区切られているかをチェックし、問題があれば CSVFormatException を投げる。
* - 正常な場合は、各行を配列に変換して返す。
*
* 3. メイン部分で、processCSV() を呼び出し、try-catch ブロックで例外を捕捉し、適切なエラーメッセージを出力してください。
*
*
*/