In article <[EMAIL PROTECTED]>, 
[EMAIL PROTECTED] says...
> I've been playing around with php alot lately and started to scheme ways to
> use it-lol
> 
> so heres what I tried to do:
> 
> first there is a switch statement:
> <?
> switch($page) {
> 
> case "refer": require("some_file.php");
> exit;
> ?>
> On that some_file.php I have an elseif like so:
> 
> <?
> 
> if($page  == $refer)
> {
> $title = "Welcome to this website";
> }
> elseif($page == $somethingelse)
> {
> $title = "Something else than the other one";
> }
> else
> {
> $title ="the default";
> }
> 
> Both these are included by:
> <?
> require('switch.php');
> require('elseif.php');
> ?>
> 
> Then on the page where thee are required I require them at the top of the
> page.
> and I have this:
> <title> echo "$title"; ?>
> The first part of the if statement returns true always.

If you think about it, it has to in the scenario you give.
if $page == 'refer' then include(somefile)

Then in somefile you again test the value of $page - which can _only_ be 
'refer'.

May I suggest you 'benchtest' your logic? Work your way through your code 
and keep track (with pencil and paper, if you like) of the values of your 
key variables at any point in the execution of the script.

And, usage of the exit() function in your Switch may not be exactly what 
you need, either; look at break!

-- 
David Robley
Temporary Kiwi!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to