【问题标题】:Defining a word in php在php中定义一个词
【发布时间】:2012-04-07 10:16:31
【问题描述】:

我是 php 的新手,很抱歉我的简单问题。需要逐步了解。

示例:index.php

<html>

<header>
-including a file (/lang.php for example)
</header>

<body>

<div>
<a href="aboutus.php"> - word1 - </a> | <a href="contact.php"> - word2 - </a>
</div>

</body>
</html>

示例:lang.php

word1 = ABOUT US
word2 = CONTACT

如何以最简单的方式完成这项工作?

【问题讨论】:

  • “最简单”的方法是在正确的位置输入ABOUT USCONTACT
  • 这很有帮助...

标签: php html word


【解决方案1】:

lang.php 将类似于:

<?php
$word1 = "About us";
$word2 = "Contact";
?>

在您的其他文件中,您将拥有

<?php
include "lang.php";
?>

<div>
<a href="aboutus.php"> - <?php echo $word1; ?> - </a> | 
   <a href="contact.php"> - <?php echo $word2; ?> - </a>
</div>

记住:

  1. PHP 中的变量名总是以$ 开头
  2. PHP 代码必须介于 &lt;?php?&gt; 标记之间(如果您的服务器配置为接受短标记,则需要在 &lt;??&gt; 之间)
  3. HTML 中没有 &lt;header&gt; 标记。也许你在想&lt;head&gt;。无论如何,include 声明不一定需要在那里

【讨论】:

  • 是啊,刚起床,可以t believe I wrote &lt;header&gt;! Ill试试这个解决方案,不过我觉得s what I一直在找。非常感谢!
  • @nico 实际上在 html 中有一个&lt;header&gt; 标签。
  • @Gabi Purcaru:酷,我不知道,我还是得好好看看HTML5。谢谢指出
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-03-20
  • 1970-01-01
  • 2010-11-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多