Solved

check if string contains any slashes

Posted on 2010-08-30
4
473 Views
Last Modified: 2012-05-10
How do I check to see if a variable contains any slashes?
0
Comment
Question by:Solutionabc
4 Comments
 
LVL 1

Expert Comment

by:d_j_twilight
ID: 33563355
Are you looking for forward (/) or back (\) slashes or both?
0
 

Author Comment

by:Solutionabc
ID: 33563376
both
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 33563391
0
 
LVL 58

Accepted Solution

by:
cyberkiwi earned 500 total points
ID: 33563421
How do I check to see if a variable contains any slashes?

$containsslashes = ((strpos($mystring, "/") === false) && (strpos($mystring, "\\") === false));
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to count occurrences of each item in an array.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question