Ir para conteúdo
Fórum Script Brasil
  • 0

how to make a php variable increase when clicking on an html button?


Rafael Cravcenco

Pergunta

Hello, I'm a beginner and I'm still learning how to work with variables
I would like to know how to make it so that when I click on the button, the variable and the text showing it increases, adding +1 to the value with each click. Can anybody help me??

My code looks like this (not sure about var_dump):

<!DOCTYPE html>
<html>
    <head>
        <title>Test PHP</title>
    </head>
    <body>
    <?php
    $var = 0;
    ?>

        <button onclick="<? var_dump(++$var); ?>"> click here </button>
    <?php
    echo $var
    ?>

    </body>
</html>
Link para o comentário
Compartilhar em outros sites

1 resposta a esta questão

Posts Recomendados

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...