【问题标题】:href link not workinghref链接不起作用
【发布时间】:2015-08-26 12:00:59
【问题描述】:

我正在从一本书中学习 PHP,我从书本网站复制了以下代码。当我在 Zend Studio 中运行它并选择任何超链接(例如 Home)时,显示的只是 php 文件的名称。例如 index.php。它不会链接到并执行 php 文件。这是为什么呢?

任何帮助将不胜感激,谢谢。

    <?php
     session_start();
?>
<!DOCTYPE html>
<html>
   <head>
        <meta charset="utf-8">
        <title>Class Registration Template</title>
        <link rel= "stylesheet" type= "text/css" href= "C:\Users\trevor.reeves\Documents\PHP&mySQLBook\php-mysql-abg-listings-1\ClassRegistration_Public/registration.css"/>
        <script type= "text/javascript"></script>
    </head>

    <body>
        <div id="wrapper">
            <div id="header">
                <img src="C:\Users\trevor.reeves\Documents\PHP&mySQLBook\php-mysql-abg-listings-1\ClassRegistration_Public/MatTechLogo.gif" alt="Matthews Technology" />
                <h1 id="title">Class Selection and Registration</h1>

            </div> <!-- id="header" -->
            <div id="hnav">
                <table width="400" border="0" cellspacing="2" cellpadding="2">
                  <tr>
                    <td><a class="hmenu" href="index.php">Home</a> </td>
                    <td><a href="index.php">About</a> </td>
                    <td><a href="index.php">Support</a> </td>
                    <td><a href="/AdministratorAuthentication/adminAuthen.php">Maintain</a> </td>
                  </tr>
                </table>

            </div> <!-- id="hnav" -->
            <div id="vnav">
                <table width="120" border="0" cellspacing="2" cellpadding="2">
                    <tr>
                        <td id="vhead">Go To: </td>
                    </tr>
                    <tr>
                        <td><a href="classlist.php">Class List</a> </td>
                    </tr>
                    <tr>
                        <td><a href="nameentry.php">Student Entry</a>
                        </td>
                    </tr>
                </table>

            </div> <!-- id="vnav" -->
            <div id="main">
                <h1 id="maintitle">Spring Class Schedule</h1>
                <p id="mainpara">Click Register to do so for a class.</p>
                <p class="red">*A footnote.</p>

            </div> <!-- id="main" -->
            <div id="footer">
                <p id="copyright">
                    Copyright &copy:2008 -
                    <?php
                         date_default_timezone_set('America/Vancouver');
                         echo date('Y');
                    ?>
                    Matthews Technology
                </p>
                <p id="contact">
                     <a href="mailto:info@matthewstechnology.com">Contact us by clicking here.</a>
                </p>
            </div> <!-- id="footer" -->
        </div> <!-- id="wrapper" -->

        <?php
         ;
        ?>
    </body>
</html>

【问题讨论】:

  • 您是否安装了XAMPP或WAMPP进行php渲染。
  • 为什么链接引用指向本地驱动器中的绝对路径? stylesheetimg 引用应该指向相对路径或 http(s) 路径
  • 小贴士:如果你想学习,千万不要复制代码,而是输入代码。
  • 我不明白这个问题。你能强调一下吗?
  • CodeGodie:当我执行列出的名为 template.php 的代码并单击超链接 Home 或 Maintain 时,Zend 不会执行那些 php 文件。它只是显示文件的名称而不做其他任何事情。

标签: php href


【解决方案1】:

您正在使用该文件引用您的磁盘操作系统来访问这些文件。您需要使用您的服务器正在使用的引用。通常它是 localhost/directory/filename.php localhost 将指向您的服务器告诉它指向的位置,该位置位于您的 php.ini 文件中。

【讨论】:

  • 它将被标记为 document_root。
  • 我尝试过绝对操作系统引用、服务器引用 (localhost/....) 以及相对引用。都做同样的事情:只显示 php 文件名。 :|
  • 感谢大家的帮助。特别是。 kayleighsdaddy。
猜你喜欢
  • 1970-01-01
  • 2017-04-10
  • 2011-07-08
  • 2020-05-09
  • 2018-04-04
  • 2011-10-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多