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 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀