okay, this is the first time I am creating a function that well actully does anything! so I was wondering if someone could look this over and tell me if its goood or not.
function includeblock();
{
$blockfile .= "block_";
$blockfile .= "$block";
$blockfile .= ".php";
if(file_exists($blockfile)){
include $blockfile;
} elseif(!file_exisits($blockfile)){
echo "Content block: $block doesn't exist";
} else {
echo "There is an error with the content block entitled: $block",
". <br>Please report this error to the site admin!";
}
}
All that function is supposed to do is test to see if a blockfile exisits, if it does then include it if not then test to see if the file doesn't exist if it doesn't then echo "BlahBlah doesn't exist" -- then if the file is there and something's screwy echo There is an error with the content block "BLAH".
Also is there a way to stop a function and not the rest of the script? will die() or exit do this?
Yes I know the above code could be much smaller, but I am not too advanced at php so.....its not smaller!
oh ya...this is all the code for this particular page:
function includeblock();
{
$blockfile .= "block_";
$blockfile .= "$block";
$blockfile .= ".php";
if(file_exists($blockfile)){
include $blockfile;
} elseif(!file_exisits($blockfile)){
echo "Content block: $block doesn't exist";
} else {
echo "There is an error with the content block entitled: $block",
". <br>Please report this error to the site admin!";
}
}
$blocks = array("login" => "Login",
"info" => "Info",
"stats" => "Stats",
"user" => "Users"
);
echo "<table align=\"center\" width=\"500\" height=\"200\" border=\"1\" cellpadding=\"0\" cellspacing=\"0\">";
foreach($blocks as $block){
echo "<tr><td>$block</td></tr>",
"<td><tr>";
includeblock();
echo "</td></tr>";
}
echo "</table>";