Page 1 of 1

Parse error when writing a simple function

Posted: Tue Oct 17, 2006 2:08 pm
by devilduckie
Hi

I'm trying to write a simple function in PHP. Basically it should replace sweden characters in a string parameter with characters that can be interpreted by all web browsers.

When I test the script I get a Parse error like this:
Parse error: parse error in /home/emergosim/scripts/laddaupp.php on line 4
Seems pretty strange since I can't see anything wrong with the function. The code looks like this:

Code: Select all

<?php
	session_start()
	
	function replace_åäö( $string )
	{
		// This function replaces the swedish characters å, ä, ö with the
		// characters a, a, o which can be interpreted by all web browsers
		$invalid = array("å", "ä", "ö");
		$valid = array("a", "a", "o");
		
		$newString = str_replace($invalid, $valid, $string);
		
		return $newString;
	}	
?>
I would appreciate if someone could lend me an extra pair of eyes to check the code for newbie mistakes?

Posted: Tue Oct 17, 2006 2:10 pm
by RobertGonzalez
Missing semicolon at the end of session_start:

Code: Select all

session_start()

Posted: Tue Oct 17, 2006 2:17 pm
by devilduckie
Thanks. :D

Hate it when that happens. :x

Posted: Tue Oct 17, 2006 3:39 pm
by RobertGonzalez
Yep, me too

/notice the missing period. ironic, eh?