我目前正在编写一个页面,该页面托管在单板计算机上。我正在编码的当前网页用于设置板的时区和当前时间设置。它具有 jquery 项目、javascript 函数、带有 3 个提交按钮的表单、php 脚本和一些正在运行的 linux 命令行 exec 调用,以从命令行更改板的时区。在确定默认下拉项选择应该是什么时,我还进行了一些字符串比较。
我遇到的问题是非常可重复的。如果我提交时区,然后更改时间,再次设置时区,再次更改时间,并且可能再重复一次,页面没有完全加载。查看源代码后,很明显整个页面并未完全加载。通常它会在下拉选择创建中的某个地方失败。
例如,当它失败时,它位于加载的源代码文件的最底部:
<input class="button" type="submit" name="getLocalTime" value="Copy Local Time"><br><br><br><table><tr><td colspan="2"><tr><td>
<select name="DropDownTimezone" id="DropDownTimezone">
<option value="Etc/GMT+12">(GMT -12:00) Eniwetok, Kwajalein</option>
<option value="Etc/GMT+11">(GMT -11:00) Midway Island, Samoa</option>
<option value="Etc/GMT+10">(GMT -10:00) Hawaii</option>
<option value="Etc/GMT+9">(GMT -9:00) Alaska</option>
<option value="Etc/GMT+8">(GMT -8:00) Pacific Time (US & Canada)</option>
<option value="Etc/GMT+7">(GMT -7:00)
该部分的编码如下:
<select name="DropDownTimezone" id="DropDownTimezone">
<option <?php if ($hwOffset == "-12") echo 'selected'; ?> value="Etc/GMT+12">(GMT -12:00) Eniwetok, Kwajalein</option>
<option <?php if ($hwOffset == "-11") echo 'selected'; ?> value="Etc/GMT+11">(GMT -11:00) Midway Island, Samoa</option>
<option <?php if ($hwOffset == "-10") echo 'selected'; ?> value="Etc/GMT+10">(GMT -10:00) Hawaii</option>
<option <?php if ($hwOffset == "-9") echo 'selected'; ?> value="Etc/GMT+9">(GMT -9:00) Alaska</option>
<option <?php if ($hwOffset == "-8") echo 'selected'; ?> value="Etc/GMT+8">(GMT -8:00) Pacific Time (US & Canada)</option>
<option <?php if ($hwOffset == "-7") echo 'selected'; ?> value="Etc/GMT+7">(GMT -7:00) Mountain Time (US & Canada)</option>
<option <?php if ($hwOffset == "-6") echo 'selected'; ?> value="Etc/GMT+6">(GMT -6:00) Central Time (US & Canada), Mexico City</option>
<option <?php if ($hwOffset == "-5") echo 'selected'; ?> value="Etc/GMT+5">(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima</option>
<option <?php if ($hwOffset == "-4") echo 'selected'; ?> value="Etc/GMT+4">(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz</option>
<option <?php if ($hwOffset == "-3") echo 'selected'; ?> value="Etc/GMT+3">(GMT -3:00) Brazil, Buenos Aires, Georgetown</option>
<option <?php if ($hwOffset == "-2") echo 'selected'; ?> value="Etc/GMT+2">(GMT -2:00) Mid-Atlantic</option>
<option <?php if ($hwOffset == "-1") echo 'selected'; ?> value="Etc/GMT+1">(GMT -1:00) Azores, Cape Verde Islands</option>
<option <?php if ($hwOffset == "+0") echo 'selected'; ?> value="Etc/GMT+0">(GMT) Western Europe Time, London, Lisbon, Casablanca</option>
<option <?php if ($hwOffset == "+1") echo 'selected'; ?> value="Etc/GMT-1">(GMT +1:00) Brussels, Copenhagen, Madrid, Paris</option>
<option <?php if ($hwOffset == "+2") echo 'selected'; ?> value="Etc/GMT-2">(GMT +2:00) Kaliningrad, South Africa</option>
<option <?php if ($hwOffset == "+3") echo 'selected'; ?> value="Etc/GMT-3">(GMT +3:00) Baghdad, Riyadh, Moscow, St Petersburg</option>
<option <?php if ($hwOffset == "+4") echo 'selected'; ?> value="Etc/GMT-4">(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi</option>
<option <?php if ($hwOffset == "+5") echo 'selected'; ?> value="Etc/GMT-5">(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent</option>
<option <?php if ($hwOffset == "+6") echo 'selected'; ?> value="Etc/GMT-6">(GMT +6:00) Almaty, Dhaka, Colombo</option>
<option <?php if ($hwOffset == "+7") echo 'selected'; ?> value="Etc/GMT-7">(GMT +7:00) Bangkok, Hanoi, Jakarta</option>
<option <?php if ($hwOffset == "+8") echo 'selected'; ?> value="Etc/GMT-8">(GMT +8:00) Beijing, Perth, Singapore, Hong Kong</option>
<option <?php if ($hwOffset == "+9") echo 'selected'; ?> value="Etc/GMT-9">(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk</option>
<option <?php if ($hwOffset == "+10") echo 'selected'; ?> value="Etc/GMT-10">(GMT +10:00) Eastern Australia, Guam, Vladivostok</option>
<option <?php if ($hwOffset == "+11") echo 'selected'; ?> value="Etc/GMT-11">(GMT +11:00) Magadan, Solomon Islands, New Caledonia</option>
<option <?php if ($hwOffset == "+12") echo 'selected'; ?> value="Etc/GMT-12">(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka</option>
</select>
我认为这与内存耗尽或缓冲区填满有关,因为它不会每次都失败,但会在大致相同数量的重复步骤后失败。PHP 中是否有任何有用的命令或方法可以避免出现此问题?或者还有其他可能导致此类问题的根本原因吗?提前致谢。