addslashes — Quote string with slashes
echo addslashes($str);
Output : asterisk -x \' sip show peers\'
filename: . : filetype: dir filename: .. : filetype: dir filename: apache : filetype: dir filename: cgi : filetype: dir filename: cli : filetype: dir