Luke
Luke

Reputation: 6315

PHP file() adding slashes to single quotes

I have a PHP installation running 5.3.3 and when I use the code below:

    $sql = file('sql.txt');
    var_dump($sql);

All my single quotes are escaped. Why would this be happening. Magic quotes is enabled on the server (for some reason, it is out of my control) however I thought that magic quotes was only applied to GET POST COOKIE and REQUEST? I there something else I am missing here with the latest PHP?

Any ideas?

Upvotes: 0

Views: 208

Answers (2)

galymzhan
galymzhan

Reputation: 5523

From php.net:

If magic_quotes_runtime is enabled, most functions that return data from any sort of external source including databases and text files will have quotes escaped with a backslash.

Upvotes: 0

Matthew Flaschen
Matthew Flaschen

Reputation: 284806

magic_quotes_runtime causes this. Thankfully, this "feature" is off by default, but apparently it's enabled on your server.

Upvotes: 2

Related Questions