基本上它是一個網頁,其中有人按下按鈕來增加$選擇變量。全局和靜態似乎不起作用。代碼如下所示:我想增加一個來自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>
跟着你的答案教程得到它做 - 謝謝! – tylercomp 2010-07-30 19:09:28