Jump to content

correct way to use backslash


jakebur01

Recommended Posts

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";
}

Link to comment
https://forums.phpfreaks.com/topic/231692-correct-way-to-use-backslash/
Share on other sites

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.)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.