Help - Search - Members - Calendar
Full Version: Switch...case... Question
Zymic Webmaster Forums > Web Design & Development > Server Side Scripting > PHP
Bogey
Am I allowed to use functions inside of switch...case... operators?

What I mean is something like the following

CODE
<?php
switch($page) {
case "default":
$sql = "CREATE TABLE DEFAULT";
$process = mysql_query($sql) or die(mysql_error());
if($process)
{
echo "DONE!";
define('DEFAULT', true);
} else {
die("<p>Error occurred on <strong>". (__LINE__) . (__FILE__) ."</strong></p>");
}
break;
case "not_default":
$this->include_form('prefs');
define('DEFAULT', false);
break;
}
?>

Or is the switch... case... operator for one line operations?

I want help ASAP biggrin.gif

- Thanks for any help here smile.gif
Ed
That's fine, but why didn't you just test it? If it was incorrect it would throw a parse error.
Bogey
I guess I'm too lazy to test it and I just went along and went with it.

Thanks for the reply Bread. Appreciate it.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2010 Invision Power Services, Inc.