I'm building a webpage that uses includes in conjunction with $PHP_SELF to supply the content. I've hit a snag though, because I'm trying to figure out a way to make it try to include a file if and only if the file exists. Here's what I'm trying to do. the top part is the interesting part.
<?php
$directory=opendir(./);
$file = (readdir($directory);
/*I need a way to say that when one of the entries in the array $file matches one of the entries from a list I provide below, do the rest of the script, otherwise, do nothing. */
while (array('writing.php','projects.php','other.php','credo.php','biography.php','scratchpaper.php','nonsense.php','otheropinions.php','news.php')
if (isset($_GET['includewriting']))
{
$includewriting=$_GET['includewriting'];
if ($includewriting=='writing.php')
{include 'writing.php'; }
if ($includewriting=='projects.php')
{include 'projects.php';}
if ($includewriting=='other.php')
{include 'other.php';}
if ($includewriting=='credo.php')
{include 'credo.php';}
if ($includewriting=='biography.php')
{include 'biography.php';}
if ($includewriting=='scratchpaper.php')
{include 'scratchpaper.php';}
if ($includewriting=='nonsense.php')
{include 'nonsense.php';}
if ($includewriting=='otheropinions.php')
{include 'otheropinions.php';}
if ($includewriting=='news.php')
{include 'news.php';}
}
?>