我的 PHP webapp 遇到了一个非常奇怪的问题。我把它设计成模块化的,我的代码被分成更小的文件,所以它不会变得过于庞大。我的应用程序是一个非营利组织的资金申请管理系统,我遇到问题的模块计算并输出自申请提交以来的营业时间。
这个“时间”模块包含在我的应用程序的多个不同部分中。在某些地方,一切正常。然而,在一个特定的地方,模块似乎没有执行,而是输出了数字“12”。这可能是因为我的代码一次执行了太多操作,导致 PHP 内存不足吗?
“时间”模块:
<?php
/* Time Module
Added for Version: 1.1
Last Updated: 10/11/2012
*/
$timeSince = time() - (int)$item['timestamp']; //Calculate the number of seconds between now and the application's submission
$timeSince = $timeSince / 60 / 60; //60secs; 60mins - Convert the seconds to hours
$timeSince = round($timeSince); //Round up or down to give us a whole number
if( //Set the highlight color to green if we're within the review timeframe.
($timeSince <= 12 && $item['appStatus']=="0") ||
($timeSince <= 48 && $item['appStatus']=="1") ||
($timeSince <= 72 && $item['appStatus']=="2")
)
$timeColor="#090";
elseif( //If we're slightly behind the timeframe, highlight as yellow
($timeSince <= 24 && $item['appStatus']=="0") ||
($timeSince <= 60 && $item['appStatus']=="1") ||
($timeSince <= 84 && $item['appStatus']=="2")
)
$timeColor="#F90";
else //If we're far behind the timeframe, highlight as red
$timeColor="#F33";
?>
Submitted: <?php echo date("F j, Y", $item['timestamp']) ?><br>
<?php if($item['appStatus']=="0" || $item['appStatus']=="1" || $item['appStatus']=="2") { ?>
<span style="color:<?php echo $timeColor ?>"><?php echo $timeSince ?></span> Hours Since Submission
<?php } ?>
包含文件的代码(在一行操作按钮下):
<div style="float:right; padding:10px; text-align:right;">
<?php if(isset($includePrefix)) { ?>
<a href="appAssets/print.php?id=<?php echo $_GET['id'] ?>" target="_blank">
<img src="appAssets/print.png" alt="Print This Application" align="middle" title="Print This Application" /></a>
<a href="mailto:<?php echo $item['agencyEmail'] ?>">
<img src="appAssets/email.png" alt="Email Agency" align="middle" title="Email Agency" /></a>
<?php if(!$hide) { ?>
<a href="#" id="disbursementLink">
<img src="appAssets/dollar.png" alt="Disbursment Instructions" align="middle" title="Disbursement Instructions" /></a>
<?php } ?>
<br />
<?php } ?>
<?php include_once("time.php") ?>
</div>