Parse error when writing a simple function

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
devilduckie
Forum Newbie
Posts: 9
Joined: Thu Sep 14, 2006 3:37 pm

Parse error when writing a simple function

Post 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?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Missing semicolon at the end of session_start:

Code: Select all

session_start()
User avatar
devilduckie
Forum Newbie
Posts: 9
Joined: Thu Sep 14, 2006 3:37 pm

Post by devilduckie »

Thanks. :D

Hate it when that happens. :x
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Yep, me too

/notice the missing period. ironic, eh?
Post Reply