php increment variable value with 1 when submit

前端 未结 4 885
温柔的废话
温柔的废话 2020-12-17 04:20

Hi I am new in php and started learning. I am trying to increment variable value with 1 when submit button is pressed.

My Code:

<         


        
4条回答
  •  一生所求
    2020-12-17 04:38

    var_dump($IsPost = !strcasecmp($_SERVER['REQUEST_METHOD'], 'POST'));
    

    ^ tells you if it's a post.

    echo ++$i;
    

    ^ increments $I and then prints $I

    echo $i++;
    

    ^ prints $I and then increments $I

    empty($_POST['submit']); // or isset($_POST['submit']);
    

    ^ tells you if ['submit'] exists in $_POST without notices.

提交回复
热议问题