graham23s Posted April 26, 2008 Share Posted April 26, 2008 Hi GUys, i wrote this basic function to deal with the ' and line breaks but im never sure in which order to apply them: <?php function clean_junk($string) { // apply the functions // $string = nl2br(stripslashes($string)); // return the string cleansed // return mysql_real_escape_string($string); } ?> i never remember in which order to apply them or does it matter? nl2br(stripslashes or stripslashes(nl2br just incase it does matter lol cheers Graham Link to comment https://forums.phpfreaks.com/topic/103048-applying-functions-in-order/ Share on other sites More sharing options...
DarkWater Posted April 26, 2008 Share Posted April 26, 2008 Use nl2br first. I think stripslashes removes the \ in \n. Not sure though. Link to comment https://forums.phpfreaks.com/topic/103048-applying-functions-in-order/#findComment-527822 Share on other sites More sharing options...
graham23s Posted April 26, 2008 Author Share Posted April 26, 2008 sounds good to me DW, ill do it that way:) Graham Link to comment https://forums.phpfreaks.com/topic/103048-applying-functions-in-order/#findComment-527833 Share on other sites More sharing options...
moselkady Posted April 26, 2008 Share Posted April 26, 2008 Looks like stripslashes() doesn't affect \n. I tried this cod in the command line and \n is still preserved: <?php $s = "1\n2\n"; echo stripslashes($s); ?> So, I think the order doesn't matter Link to comment https://forums.phpfreaks.com/topic/103048-applying-functions-in-order/#findComment-527836 Share on other sites More sharing options...
graham23s Posted April 26, 2008 Author Share Posted April 26, 2008 thanks for testing mate:) Link to comment https://forums.phpfreaks.com/topic/103048-applying-functions-in-order/#findComment-527853 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.