escapeshellarg

string escapeshellarg(string arg) 

Makes a string safer to use as an argument for a shell command.

Returns:

Single-quote delimited string, with all other single quotes in the string quoted and escaped

Description:

escapeshellarg() converts a scalar value into a single-quote delimited string that can more safely be used as a single argument for a shell command.

Any existing single quotes (') in the value are converted to '\''. This sequence temporarily ends the single-quoted string, inserts a literal single quote, and then resumes the string. This is necessary because shells don’t interpolate the characters inside a single-quoted string.

Single-quoted strings are safer for use as shell arguments because the shell performs no variable ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.