There is a constant available, it is called DIRECTORY_SEPARATOR
.
$path_to_file = $directory . DIRECTORY_SEPARATOR . $file
It‘s documented here: http://php.net/manual/en/dir.constants.php#constant.directory-separator
Be advised that PHP handles this internally, so on Windows you may get a forward slash, but they will work just fine inside PHP!