Sunday 20 July 2014

Hello everyone..

 

There is a problem with this PHP code... 

 

PHP developers find it out..



 
<?php
$badinput=false;

function check($arg1,$arg2)
{
    if(($arg1<0)||($arg1>100))
    {
    $badinput=true;
    }

    if(strlen($arg2)>32)
    {
    $badinput=true;
    }
}

$val=499;
$name="Unexpected results or non-execution ";

check($val,$name);

if(!$badinput)
    echo "Good";
else 
    echo "Bad input";
?>
 

waiting for solution...


Please leave a reply..

 

Regards : M2 Software solutions Pvt. Ltd.


 

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
    Replies
    1. The problem was in your "CHECK" function and "IF" at the end of file.

      function check($arg1,$arg2)
      {
      if(($arg1<0)||($arg1>100) && strlen($arg2)>32)
      {
      return TRUE;
      } else {
      return FALSE;
      }
      }

      $val=101;
      $name="Unexpected results or non-execution ";

      $badinput = check($val,$name);

      echo ($badinput === TRUE ? 'GOOD': 'BAD INPUT!');

      Delete
    2. yes thats the error... thanks for replying...

      Delete

  • RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
  • Youtube