title: How to validate IPv6 using filter_var()?
body: <p>I am trying to filter IPv6 from the input. I tried to input IPv4 in the field in the form, in this case the else statement must be executed but the condition was true. I mean both IPV4 &amp; IPV6 are true.</p>
  
  <p>How can I make that example more specific?</p>
  
  <p>php:</p>
  
  <pre><code>&lt;?php
  $input = $_POST['test'];
  
  $opt = array (
  
          'options' =&gt; array (),
          'flags'   =&gt; FILTER_FLAG_IPV6
  );
  
  if (filter_var($input,FILTER_VALIDATE_IP,$opt) !== FALSE) {
      echo 'Good (' . $input . ') is ip version 6';
  } else {
  
      echo 'Sorry (' . $input . ') is not ip version 6';
  }
  </code></pre>
  
  <p>form: </p>
  
  
  
  <pre><code>&lt;form action="checkinput.php" method="post"&gt;
    &lt;input type="text" name="test"&gt;
    &lt;input type="submit" value="Send"&gt;
  &lt;/form&gt;
  </code></pre>