[SOLVED] alternative to php switch case for include?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

User avatar
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

Post by bironeb »

Well i replaced my case.php code with:

Code: Select all

<?php 
if (file_exists("\includes" . $mlink . ".php")) { 
   include("includes" . $mlink . ".php"); 
} 
?>
and i get this error

Parse error: parse error in c:\apache\htdocs\includes\case.php on line 3
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

You do not escape things properly. Try:

Code: Select all

if (file_exists("includes" . basename($mlink) . ".php")) { 
   include("includes" . basename($mlink) . ".php"); 
}
User avatar
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

Post by bironeb »

Cool Weirdan, That worked...

what do you mean by:
You do not escape things properly.
Im still a PhP Newbie, but i really appreciate all the help.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

read this page
User avatar
bironeb
Forum Commoner
Posts: 59
Joined: Thu Nov 20, 2003 12:02 pm

Post by bironeb »

Thanks again Wierdan, and all who contributed!
Post Reply