Saragon Posted June 9, 2006 Share Posted June 9, 2006 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 <?php2 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 https://forums.phpfreaks.com/topic/11594-parsing-error/ Share on other sites More sharing options...
poirot Posted June 9, 2006 Share Posted June 9, 2006 Don't use curly brackts, but round brackets or parentheses:[code]function stripFormSlashes($arr)[/code] Link to comment https://forums.phpfreaks.com/topic/11594-parsing-error/#findComment-43765 Share on other sites More sharing options...
Saragon Posted June 9, 2006 Author Share Posted June 9, 2006 [!--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 https://forums.phpfreaks.com/topic/11594-parsing-error/#findComment-43767 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.