Php foward slash within quotations

Discussion in 'PHP' started by mpea, Nov 21, 2007.

  1. #1
    okay, its a simple question, but I have no idea how to search for this.

    How can I put a forward slash within quotes.

    I have a problem, a string gets converted to "xyz/" and is then put in an sql querry, how can I detect the slash, I cant use: strpos($encPass, "\" ) > -1
    Since the \ makes the quotation a non surrounding quotaion.. so what can I use to detect a forward slash?
     
    mpea, Nov 21, 2007 IP
  2. ehlokoen

    ehlokoen Peon

    Messages:
    161
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Use "\\" :) That will work. The first slash escapes the second one.
    EDIT: And oh, since you are looking for xyz/, you might be trying "/" instead of "\\" ??
     
    ehlokoen, Nov 21, 2007 IP
  3. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #3
    You are asking about detecting slashes yet your example is for a backslash?

    Check for backslash: strpos($encPass, '\\')
    Check for slash: strpos($encPass, '/')
     
    krt, Nov 21, 2007 IP
  4. mpea

    mpea Guest

    Messages:
    272
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    0
    #4
    opps my example was wrong, I did mean xyz\

    Ill try \\ , thanks
     
    mpea, Nov 21, 2007 IP
  5. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #5
    Ok, then yes, \\ is right, the first backslash escapes the second resulting in a literal backslash.
     
    krt, Nov 21, 2007 IP