SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: filter_var

  1. #1
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    filter_var

    I am not sure if I am using the filter_var command correctly. Regardless of what $src_term is it always sees the statement as false. Can anyone see where I am going wrong with this?

    PHP Code:

    $filter
    ="FILTER_VALIDATE_INT";
    $error="Bad!";
    $src_term "aaaaaaaaaaaaaa";
        
    if (
    filter_var($src_term$filter) == FALSE)
        {
                echo 
    htmlspecialchars($errorENT_QUOTES'UTF-8');
                exit();
        }
        else{
            echo 
    "good";    
        } 

  2. #2
    @php.net Salathe's Avatar
    Join Date
    Dec 2004
    Location
    Edinburgh
    Posts
    1,396
    Mentioned
    61 Post(s)
    Tagged
    0 Thread(s)
    The filter should be one of the filter constants, not a string.

    PHP Code:
    $filter FILTER_VALIDATE_INT
    Salathe
    Software Developer and PHP Manual Author.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2006
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent ... thank you very much


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •