2013-03-17 128 views
2

我觉得我做的事情基本上是错误的。这里是我的代码水珠()不是搜索文件夹

的index.php

<?php 

if(isset($_POST['a'])){ 
    $action = $_POST['a']; 
} else if(isset($_GET['a'])){ 
    $action = $_GET['a']; 
} else { 
    $action = "home"; 
} 


if($action == "home"){ 
    $frontImages = glob('assets/images/frontpage/*'); 
    include_once 'home.php'; 
} 
?> 

var_dump($frontImages)homp.php(其中顺便说一句是显示就好了),但我收到$frontImages是一个不确定的变量中。无论是index.php文件和文件home.php是在根文件夹,这里是路径目录的图像:

enter image description here

所以不知道我在做什么错在这里。

+1

你试过'的var_dump($ _ POST [ '一']);'和'的var_dump($ _ GET ['一']);'?甚至直接使用'$ frontImages = glob('assets/images/frontpage/*'); include_once'home.php';'没有if/else语句...? – HamZa 2013-03-17 15:17:31

+2

发布您的整个代码将帮助我们更好。要添加,你有没有尝试删除'*'? – 2013-03-17 15:20:39

+0

我试过所有的变量,它们都显示为未定义的变量。不知道什么是错的。所有的.php文件都在../bygg/ – user1683645 2013-03-17 15:25:31

回答

0

使用

<?php 

if(isset($_REQUEST['a'])) { 
    $action = $_GET['a']; 
} else { 
    $action = "home"; 
} 


if($action == "home"){ 
    while($acImg = glob('assets/images/frontpage/*')) { 
     $frontImages[] = $acImg; 
    } 
    include_once 'home.php'; 
} 
?> 

现在你有一个数组,但这个工程由我