Jump to content

Parsing error


Saragon

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?
Link to comment
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.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.