summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorHartmut Holzgraefe <hholzgra@php.net>2003-04-26 15:20:18 +0000
committerHartmut Holzgraefe <hholzgra@php.net>2003-04-26 15:20:18 +0000
commitf8f4e049098a4eaa63e5cda71ff7882e0655b7fd (patch)
treed458f450a99432595b785ee4b07644a81802ca8d /scripts
parent5e5ddac9f11acff28eec38e159bb50d117c93d0d (diff)
downloadphp-git-f8f4e049098a4eaa63e5cda71ff7882e0655b7fd.tar.gz
support arrays of error messages in addition to single strings
use PHP 5 style __constructor
Diffstat (limited to 'scripts')
-rw-r--r--scripts/ext_skel_ng/xml_stream_parser.php22
1 files changed, 17 insertions, 5 deletions
diff --git a/scripts/ext_skel_ng/xml_stream_parser.php b/scripts/ext_skel_ng/xml_stream_parser.php
index 25c3c548e9..fe0a4c9ad7 100644
--- a/scripts/ext_skel_ng/xml_stream_parser.php
+++ b/scripts/ext_skel_ng/xml_stream_parser.php
@@ -2,10 +2,10 @@
class xml_stream_parser {
var $parser;
- function xml_stream_parser($stream)
+ function __construct($stream)
{
- if(!is_resource($stream)) die("not a stream");
- if(get_resource_type($stream) != "stream") die("not a stream");
+ if (!is_resource($stream)) die("not a stream");
+ if (get_resource_type($stream) != "stream") die("not a stream");
$this->parser = xml_parser_create();
@@ -14,7 +14,7 @@ class xml_stream_parser {
xml_set_character_data_handler($this->parser, "cdata");
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, false);
- while(!feof($stream)) {
+ while (!feof($stream)) {
xml_parse($this->parser, fgets($stream), feof($stream));
}
xml_parser_free($this->parser);
@@ -35,7 +35,19 @@ class xml_stream_parser {
var_dump($parser, $tag);
}
- function error($msg) {
+ function error($msg)
+ {
+ if (is_array($msg)) {
+ if (count($msg)==1) {
+ $msg = current($msg);
+ } else {
+ foreach ($msg as $text) {
+ echo "$text\n";
+ }
+ $msg = "...";
+ }
+ }
+
die("$msg on line ".xml_get_current_line_number($this->parser));
}
} // end of class xml