dsa80833 2012-10-15 15:44
浏览 22
已采纳

从外部php文件调用PHP

What I am trying to do is put all of my variables in an external php file and then call them on different pages. I am creating workflows for multiple projects, all of these projects follow the same flow but have some different information like phone numbers and fees for things. So what I am trying to accomplish is put all of my variables in an external file so if something changes for a project I can edit the one file versus open up the 23 different workflows I have created.

This is just a sample of all the external file will have but for 31 different projects and 14 different variables for each.

<?php
$project_id = $_GET["project_id"];

switch ($project_id) {
case "fl":
    $title = "Florida EPC";
    $replacement_fee = "$4";
    break;
case "tx":
    $title = "Texas EPC";
    $replacement_fee = "$6";
    break;
}
?>

Then just a basic rundown of each workflow

<div id='a1' style="display:block;">
<div align="center" style="border-bottom: 1px solid black;">
<b>Check the CARDS tab for the PAN.</b><br /><br />

</div>
&nbsp;
 <div align="center">
<p><i>"I'm sorry to hear you have lost your card. I can cancel the Lost card for your protection."</i></p><br><br>
 <font color="red">Was the PAN issued?</font><br /><br />
<a class="button" href="javascript:switchid('a2');"><span>Yes</span></a>&nbsp;&nbsp;
<a class="button" href="javascript:switchid('a3');">No</a>
</div>
</div>

<div id='a2' style="display:none;">
<div align="center">
<p><b>Advise the client the card was previously cancelled.</b></p>
<p><i>"Your card has already been deactivated as of (date of deactivation)."</i></p>    <br><br>
<font color="red">Is the address up to date?</font><br /><br />
<a href="javascript:switchid('a4');">Yes</a>&nbsp; &nbsp;
<a href="javascript:switchid('a5');">No</a>
</div>
</div>

within some of the divs all i will put is <?php echo $avariable; ?> when the different info will be used. I just need to beable to call the external file on each workflow and can't figure that part out.

  • 写回答

3条回答 默认 最新

  • douan3019 2012-10-15 15:45
    关注

    what you need is the require_once statement.

    More info at http://php.net/manual/en/function.require-once.php

    require_once can be used at the top of all of your pages and will only include the file a single time even when includes are nested.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 求学软件的前人们指明方向🥺
  • ¥50 如何增强飞上天的树莓派的热点信号强度,以使得笔记本可以在地面实现远程桌面连接
  • ¥15 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services