stripslashes

  • You’ll rarely need to strip slashes in Ruby, since there is no equivalent of PHP’s magic_quotes_gpc directive. Stripping slashes would be done with String#gsub to do substitution just like addslashes.

    PHP

    $result = stripslashes('I can\\\'t imagine \\"that\\"!\\0');
    var_export($result);
    // => 'I can\'t imagine "that"!\000'

    Ruby

    string = "I can\\'t imagine \\\"that\\\"!\\\000"
    p string.gsub("\\", "")
    # => "I can't imagine \"that\"!\000"
    

    see also

strip_tags strlen

Looking for Rails or PHP web application development, integration, and training?

Rails for PHP is brought to you by Maintainable Software. Get custom web applications and personalized training from the authors of the book and website.