Strange problems with classes

From: Date: Wed, 02 Feb 2000 18:48:48 +0000
Subject: Strange problems with classes
Groups: php.dev 
Request: Send a blank email to php-dev+get-15149@lists.php.net to get a copy of this message
This message was sent from Geocrawler.com by "Ross Burton" <rossyb@email.com> Be sure to reply to that address. I am having problem in PHP 4.0b3. Basically: * my code works in PHP 3.0.9 * the server it is to go on uses PHP 4.0b3 I upgraded to PHP 4.0b3 and my code still works (as long as the include file with a class declaration in has unix line breaks - it fails with DOS line breaks). However, when I place it on the server it fails, as far as I can tell PHP is crashing as the connection is forcibly terminated by Apache (no data is sent). Attached is my code: index.php: <HTML> <HEAD> <TITLE>KCL | War Studies</TITLE> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> <LINK REL="stylesheet" HREF="style.css"> </HEAD> <BODY BGCOLOR="#FFFFFF"> <H3>Latest News</H3> <UL> <?php $webroot = "/usr/local/www/kcl/kis/schools/hums/war/"; $path = $webroot."news/"; $titlestrip = "KCL | War Studies | "; function FormatArticle($news) { print '<LI><B><A HREF="'.$news- >url.'">'.$news->title.'</A></B><BR>(posted >'.date ("l j F", $news->date).')</LI>'."n"; } function cmp($a, $b) { return $a->reverseDateSort($b); } require("./newslib.php.inc"); ?> </UL> </BODY> </HTML> newslib.php.inc: <?php class News { var $title; var $url; var $date; function News($ntitle, $nurl, $ndate) { global $title, $url, $date, $output; $this->title = $ntitle; $this->url = $nurl; $this->date = $ndate; } function reverseDateSort($another) { global $date; if ($this->date == $another- >date) return 0; return ($this->date > $another- >date) ? -1 : 1; } } $dirlist = dir($path); while($entry=$dirlist->read()) { if(is_file($path.$entry)) { $fp = fopen($path.$entry, "r"); $result = "Untitled"; $count = 10; while($count > 0) { $templine = fgets($fp, 1024); --$count; if (eregi("<TITLE>(.+) </TITLE>", $templine, $regex)) { $result = $regex [1]; $result = str_replace($titlestrip, "", $result); $count = 0; } } fclose($fp); $title = htmlspecialchars ($result); $url = substr($path.$entry, strlen($webroot)); $date = filemtime($path.$entry); $articles[] = new News($title, $url, $date); } } $dirlist->close(); // Sort the array usort($articles, cmp); // Display them for ($i = 0; $i < sizeof($articles); ++$i) { FormatArticle($articles[$i]); } ?> Any help would be appreciated! Thanks, Ross Burton Geocrawler.com - The Knowledge Archive

« previous php.dev (#15149) next »