<?php

    $string = "/var/www*/te'st/test.php";
    $string = preg_replace( '/[^A-Za-z0-9\-\\.\/]/', '' , $string );
    echo $string;