dshw124502
2016-11-17 16:44 阅读 200

转义具有单反斜杠和双反斜杠的Windows服务器文件路径字符串?

I have a Windows server file path that I'm having a lot of difficulty escaping because of PHP's magic quotes feature. Assuming that turning this setting off isn't trivial, how would I go about escaping this path?

Example:

\\SERVER\folder1\folder2\folder3\file.dtsx

To complicate things further, this path would need to run as part of a command wrapped in another set of quotes since it ultimately runs via a command prompt utility (called in SQL). The full command would look something like this:

$package =
            'dtexec.exe /f "\\SERVER\folder1\folder2\folder3\file.dtsx" ' + 
            '/set \Package.Variables[User::Param1].Properties[Value];"' + CAST(@param1 AS varchar) + '" ' + 
            '/set \Package.Variables[User::Param2].Properties[Value];"' + CAST(@param2 AS varchar) + '" ' + 
            '/set \Package.Variables[User::Param3].Properties[Value];"' + CAST(@param3 AS varchar) + '"';

I think my main challenge is the server file path if anyone can lend a hand here, though! Thanks in advance!

Dan

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

相关推荐