Fondamentalement, c'est une page Web où quelqu'un appuie sur un bouton pour incrémenter la variable de sélection $. Globals et statiques ne semblent pas fonctionner. code ressemble à ceci:Je veux incrémenter une valeur à l'extérieur d'un bloc php
<?php
if(isset($_POST['next']))
{
displaynext();
}
else
{
global $image_folder = "/images/";
echo "global declared";
global $selection;
$selection = 1;
}
function displaynext()
{
$selection++;
if (file_exists($image_folder."/".$selection.".png")) {
echo "<img src=\"$image_folder/".$selection.".png\">";
}
else {
echo "No next image was found for $selection in ".$image_folder."/".$selection.".png";
}
?>
<form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
<input type="submit" name="next" value="Next">
</form>
suivi tutoriel dans votre réponse avons réussi, - merci! – tylercomp