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条)

报告相同问题?

悬赏问题

  • ¥50 求解vmware的网络模式问题
  • ¥24 EFS加密后,在同一台电脑解密出错,证书界面找不到对应指纹的证书,未备份证书,求在原电脑解密的方法,可行即采纳
  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥30 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?