Jump to content

Archived

This topic is now archived and is closed to further replies.

Saragon

Parsing error

Recommended Posts

The following is lifted straight out of Christian Wenz's "PHP Phrasebook: Essential Code and Commands". It's a handy function designed to clean extra "magic quotes" slashes out of form data.

Unfortunately, it's throwing a parse error that seems completely unreasonable. The error is as follows:
[b]Parse error:[/b] parse error, unexpected '{', expecting '(' in [server root]/[subdirectories]/stripFormSlashes.inc.php on line 2

[code]1 <?php
2     function stripFormSlashes{$arr}
3     {
4       if (!is_array($arr)) {
5         return stripslashes($arr);
6       } else {
7         return array_map('stripFormSlashes', $arr);
8       }
9     }
10    
11     if(get_magic_quotes_gpc()) {
12       $_GET  = stripFormSlashes($_GET);
13       $_POST = stripFormSlashes($_POST);
14     }
15 ?>[/code]

I'm calling this with the following:
[code]<?php require_once 'stripFormSlashes.inc.php'; ?>[/code]

Now, as near as I can tell, line 2 is just fine. So is the rest of the code, for that matter -- I've no unclosed parentheses anywhere. Nonetheless, it simply will not parse. What obvious thing have I overlooked here?

Share this post


Link to post
Share on other sites
Don't use curly brackts, but round brackets or parentheses:

[code]function stripFormSlashes($arr)[/code]

Share this post


Link to post
Share on other sites
[!--quoteo(post=381981:date=Jun 9 2006, 02:04 PM:name=poirot)--][div class=\'quotetop\']QUOTE(poirot @ Jun 9 2006, 02:04 PM) [snapback]381981[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Don't use curly brackts, but round brackets or parentheses:

[code]function stripFormSlashes($arr)[/code]
[/quote]

I also apparently need to get my eyes checked. Or I need to get a new monitor -- I can barely distinguish between the two in PHP Designer `06. Hmm.

Thanks, Poirot.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.