Warning: preg_replace(): No ending delimiter '

2019-03-27 13:36发布

Warning: preg_replace(): No ending delimiter '/' found in C:\wamp\www\upload\upload_demo.php on line 77 I used preg_replace() to replace slash to backslash. But it shows the above warning. Here is the code..

function del_file($file) {
$delete = @unlink($file);
clearstatcache();
if (@file_exists($file)) {
    $filesys = preg_replace("/", "\\\\", $file);
    $delete = @system("del $filesys");
    clearstatcache();
    if (@file_exists($file)) {
        $delete = @chmod($file, 0775);
        $delete = @unlink($file);
        $delete = @system("del $filesys");
    }
}

1条回答
乱世女痞
2楼-- · 2019-03-27 14:09

Use str_replace, or add delimiters to pattern if you really need preg_replace.

$filesys = str_replace("/", "\\\\", $file);

OR

$filesys = preg_replace("~/~", "\\\\", $file);
查看更多
登录 后发表回答