I met some trouble with a function.

In fact I would like to include all my pages, but the thing is that not all pages are named like the param $_GET['page'] for example if I call index.php?p=accueil it will redirect to php/home.php

an other example if I call index.php?p=message it will redirect transparently to message.php

For all exceptions I've generated an array like that:

<?php    
$paramListepages = array(       
     'corbeille' => array(
         'libelle'     => 'corbeille',
         'page'        => 'php/trash.php'
     ),   
     'nouveaumessage' => array(
         'libelle'     => 'nouveaumessage',
         'page'        => 'php/envoyer.php'
     )  
);
?>

This array contain many sub_arrays As you can see the 2 firsts of this one.

For calling pages I've done a function like that:

function getPage($var) {
    if (!isset($var)){
        //Aucune page spécifiée => default page
        inlude('php/accueil.php');
    }
    elseif (array_key_exists($var,$paramListepages)){
        // page trouvée => on l'inclut!
        include ('php/accueil.php');
    }
    else{
        // page espectant la structure, non trouvée dans l'array => on l'inclut directement
        include('php/'.$var.'.php');    
    }
}

actualy it seems to recognise the if condition and the else.

But when I ask for a page in the array, there is a blank page It seems to not be able to read the correct value expected.

I have white empty pages with no mistake or message error.

In my Ubuntu I've activated the error_reporting(E_ALL);

Any kind of help will be much appreciated

share|improve this question

80% accept rate
Interesting, the way you changed my code I answered your previous question with. Interesting cause you broke it by exchanging the last two include statements. – arkascha 16 mins ago
1  
And why do you insist on the isset() at the start? $var is declared as function argument, it is impossible it dies not exist there. You want to use empty(), as I suggested. – arkascha 15 mins ago
actualy it does not work with the previous version and when I validated your code I was not able to change it – Stanislas Piotrowski 14 mins ago
What does "not work" mean? Track down what page actually gets called by looking at the servers log files. No sense in guessing what might happen. – arkascha 13 mins ago
@arkascha You don't want to use empty either, since empty is !isset($var) || !$var. Just use !$var. – deceze 13 mins ago
show 10 more comments
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.