目录类不工作php&;xmapp

目录类不工作php&;xmapp,php,xampp,rewrite,Php,Xampp,Rewrite,我试图创建一个文件目录,但问题是我的索引页加载,但它是一个空白页。下面是我所拥有的 index.php <!DOCTYPE html> <html lang="en-GB"> <?php require_once ("../app/views/nav.php"); <body <p> test </p> </body </html> ?> nav.php <div> <ul> &l

我试图创建一个文件目录,但问题是我的索引页加载,但它是一个空白页。下面是我所拥有的

index.php

<!DOCTYPE html>
<html lang="en-GB">
<?php
require_once  ("../app/views/nav.php");
<body
<p> test </p>
</body
</html> 
?>

nav.php
<div>
<ul>
<li>
<a href="<?php fetchdir($views); ?>">TEST</a>
</li> 
</ul>

directories.class.php
  class directories{
    function __construct(){
    //I am not using a database so I don't know what to put here
    }

    function fetchdir($dir) {

        $host = $_SERVER['HTTP_HOST'].'/'; // The website host 
        $protocol = strpos(strtolower($_SERVER['SERVER_PROTOCOL']),'https') === FALSE ? 'http://' : 'https://'; //The HTTP(S) protocol 
        $branch = ""; // Dirs in URL from host to main folder

        $protocol = $GLOBALS['protocol'];
        $host = $GLOBALS['host'];
        echo $protocol.$host.$branch.$dir;
    }

}

$views = "views/";
 $root = new directories;
页面将被加载

其他信息

我的
httpd vhosts.conf
如下所示

<VirtualHost *:80> 
  DocumentRoot "c:\Users\MYNAME\web-test\teDt202\web\html" 
  ServerName teDt202.local 
  <Directory c:\Users\MYNAME\web-test\teDt202\web> 
    # Apache 2.2 style access control (DEFAULT)  
    # Order allow,deny  
    # Allow from all 

    # Apache 2.4 style access contol (comment the next line if you're using below Apache 2.4)  
    Require all granted  

    AllowOverride all 
  </Directory> 
  AddHandler php5-script .htm 

  Alias /main c:\Users\MYNAME\web-test\teDt202\web\main
  RewriteEngine on 
  RewriteCond %{LA-U:REQUEST_FILENAME} !-f 
  RewriteRule /(.*)$ /main/index.php/$1 [NS,PT,L] 

</VirtualHost>

DocumentRoot“c:\Users\MYNAME\web测试\teDt202\web\html”
服务器名teDt202.local
#Apache 2.2风格的访问控制(默认)
#命令允许,拒绝
#通融
#Apache2.4风格的访问控制(如果您在Apache2.4下面使用,请在下一行注释)
要求所有授权
允许超越所有
AddHandler php5 script.htm
别名/main c:\Users\MYNAME\web测试\teDt202\web\main
重新启动发动机
重写cond%{LA-U:REQUEST_FILENAME}-F
重写规则/(.*)$/main/index.php/$1[NS,PT,L]
文件夹结构

teDt202 <---main folder
web 
app
  classes <!-- all my class files are in here
  views <!-- I have all my .php files are in here
html <!-- I have my css, js and images files here
main
 index.php

teDt202您有一个名为
fetchdir()
的函数,但它驻留在一个类中,因此,如果不先实例化该类,然后将该函数本身作为类的方法调用,则无法直接调用该函数

$directories = new directories;

<a href="<?php $directories->fetchdir($views); ?>">TEST</a>
$directories=新目录;

感谢您的重播,我确实实例化了该类,但发生了两件事:1)我的页面加载没有css;2)当我单击导航中的链接时,我得到了如下内容
http://teDt202.local/%3Cbr%20/%3E%3Cb%3ENotice%3C/b%3E:%20%20Undefined%20index:%20protocol%20in
blah@user3057514那是个错误。你可以从中看出这是一个错误<代码>未定义的索引协议
$directories = new directories;

<a href="<?php $directories->fetchdir($views); ?>">TEST</a>