Home > Software design >  I am trying to set boundary for my autoincrement function
I am trying to set boundary for my autoincrement function

Time:12-08

I am trying to set boundary for my autoIncrement fuction and everything looks right but nothing is showing on my screen. I also tried to use var_dump() function but its not showing any result. Please, what am I missing?

I invoke the function and it is not showing any result. I also tried to dump the data using var_dump() function but its still the same error.

below is the snippet

<?php
 function autoIncrement(){
        $num = 0;
        if($num > 10){
            echo "Maximum number selected";

           }else{
        for ($num; $num <=10; $num  ){

           if($num > 10){
            echo "Maximum number selected";

           }else{
            echo $num . ", ";
           }
            //var_dump($num);  

        }
        
        }
      autoIncrement();

    }

?>

CodePudding user response:

You made a mistake when you invoke your function "autoIncrement()". You dont invoke a function inside your function but outside of it.

see below code

<?php

function autoIncrement(){
    $num = 0;
    if($num > 10){
        echo "Maximum number selected";

       }else{
    for ($num; $num <=10; $num  ){

       if($num > 10){
        echo "Maximum number selected";

       }else{
        echo $num . ", ";
       }
        //var_dump($num);  

    }
    
    }
    
}
autoIncrement();



?>
  • Related