jakebur01 Posted March 25, 2011 Share Posted March 25, 2011 What is the correct way to use the backslash here? I am using an ftp script and retrieving the brand directory name through url. I want to catch it if they try to use \ in the url to list all directories. elseif($_GET[f]=="\") { echo "You have entered an invalid vendor."; $_SESSION['brand_path'] = "INVALID"; } Quote Link to comment https://forums.phpfreaks.com/topic/231692-correct-way-to-use-backslash/ Share on other sites More sharing options...
DavidAM Posted March 25, 2011 Share Posted March 25, 2011 Backslash in a double-quoted string escapes the next character, so you would escape the backslash that you want with a backslash: elseif($_GET['f']=="\\") I'll admit it looks confusing, but that's they way it works. (Also, you should put quotes around the array keys when they are strings.) Quote Link to comment https://forums.phpfreaks.com/topic/231692-correct-way-to-use-backslash/#findComment-1192241 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.