Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

I am trying to set boundary for my autoincrement function

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

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

<?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();

    }

?>

>Solution :

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();



?>
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading