Re: support for php3 ?!?!?
Brought to you by:
iridium
From: Martin G. <gim...@gi...> - 2002-02-03 09:58:25
|
"Ray van Beek" <r_v...@ho...> writes: > Hi all! > > My hosting provider runs php 3.0.3 (I know, I know!). OK - but you have told them to upgrade, haven't you? > Phpweather 1.59 does not run on this php, it crashes to some > functions that are used (like extract and str_replace). I see - the manual explains that they were added in PHP version 3.0.7 and 3.0.6, respectively. > Was there some previous phpweather version that ran on php 3.0.3? Or > do I have to 'down-tune' the latest version to make it work? Instead of down-tuning, you could implement the two missing functions yourself: function extract($array) { while (list($key, $val) = each($array)) { $GLOBALS[$key] = $val; } } function str_replace($search, $replace, $subject) { $search_length = strlen($search); $replace_length = strlen($replace); $i = 0; while ($i < strlen($subject)) { if ($search == substr($subject, $i, $search_length)) { $subject = substr($subject, 0, $i) . $replace . substr($subject, $i+$search_length); $i += $replace_length; } else { $i += 1; } } return $subject; } I don't know if these functions work in PHP3, but I've tried to restrict myself to functions that existed in PHP3, according to the manual. If the work, then I'll put them into two files, extract.php and str_replace.php and include them in the tarball, so that people who lack them can include the files before including the other PHP Weather files. How does that idea sound? -- Martin Geisler My GnuPG Key: 0xF7F6B57B See my homepage at http://www.gimpster.com/ for: PHP Weather => Shows the current weather on your webpage. PHP Shell => A telnet-connection (almost :-) in a PHP page. |