phplaravel-4wordpress-themingstripslashes

What is the right way to print escaped strings, and to hide backslashes on users end?


I'm building a website using Laravel 4. I'm using triple "{" while printing data from the database, or data that can be user manipulated but I have a dilemma here. When special characters are used they are escaped with a "\", but I don't want the "\" to appear on the site.

So my question is how to print these strings the right way? I know I can use stripslashes to remove the "\", but is this safe? The slashes are added there for a reason so just stripping them would't be a problem? Is there a better/safer way to achieve this?

Note: I'm not asking for a Laravel approach only, I'm also open to pure php suggestions.

Thanks.


Solution

  • I found the cause of this after all. In the public folder of this website we also have wordpress installed to be used as a CMS for our blog section of the website. It seems that WordPress was altering the $_POST/$_GET variables.

    The solution for this was to capture the $_GET, $_POST and $_REQUEST variables in a temporary array before the wordpress is initialized in public/index.php and reassign them the values from that array after wordpress is initialized.

    $tmp = array($_GET, $_POST, $_REQUEST);
    

    -

    /**
    *   Include wordpress
    */
    define('WP_USE_THEMES', false);
    require __DIR__.'/wordpress/wp-blog-header.php';
    

    -

    list($_GET, $_POST, $_REQUEST) = $tmp;