Jump to content

Php Inclusions.


cpugeek

Recommended Posts

Okay, so i have this code:

<?php  $x=basename($_GET['x']);  $allow=array('index', 'default', 'pageone', 'pagetwo', 'pagethree'); // Take out whatever files you want, or add more  if (file_exists("$x.php") && in_array($x, $allow)) {	include("$x.php");  }  else {	include("default.php");  }?>

& it works but i was wondering if there is a way i could do it without an array.Or if i could include the array.Any & All help is appreciated

Link to comment
Share on other sites

what modifications to my code would i have to make?what would my code look like?because i think you might have misunderstood.what i want is to include my array from an exterior file so that there isn't a long line of files.i was just wondering if i could include the array like a regular file.like so:index.php

<?php  $x=basename($_GET['x']);	include("array.php");  if (file_exists("$x.php") && in_array($x, $allow)) {	include("$x.php");  }  else {	include("default.php");  }?>

array.php

$allow=array('index', 'default', 'pageone', 'pagetwo', 'pagethree'); // Take out whatever

or something like that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...