newbie here....

Discussion in 'PHP' started by puknene, Apr 4, 2006.

  1. #1
    How do i check the string if it contains characters like (!@#$%^&*()|?/.,"')
     
    puknene, Apr 4, 2006 IP
  2. puknene

    puknene Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    i have found this code on the net :

    $check = substr_count($string, '@');

    ---------------------------------------------------

    If $check is not 0 then $string contains the character. How do i check for other characters in just some lines of script?
     
    puknene, Apr 4, 2006 IP
  3. cyphix

    cyphix Well-Known Member

    Messages:
    245
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    103
    #3
    Look into these functions..

    strpos()
    preg_match()

    In your case I would be definitely suggest using preg_match().
     
    cyphix, Apr 5, 2006 IP
  4. puknene

    puknene Peon

    Messages:
    5
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    how..? can someone make one for me..

    I only know to check it one by one... is there a way to make it in just a few lines?

    sample :

    $str = "abcdefghijklmnop*%$@&#&*";
    echo strpos($str, '%'); // outputs 1



    what if i want to check a series of character *&*$.. how do i do it in just a few lines?
     
    puknene, Apr 6, 2006 IP