On Fri, August 18, 2006 11:58 am, Tom Cruickshank wrote:
> Would anyone know if it's possible to have dynamic case
> statements?
Almost for sure...
I *know* you can use switch(true) and put *ANY* expression you want
for a case.
switch (true) {
case $temp === 'status':
$theform->status();
break;
case $temp:
$theform->form($temp);
break;
}
> Theform = new form();
>
> $temp = $_POST['var1'];
>switch ($temp) {
> case "status":
> $theform->status();
> break;
>
> case $temp:
> $theform->form($temp);
> break;
> }
This, however, is probably better handled with a 'default:' instead of
case $temp...
> This keeps giving me Call to undefined method form::form() in
> /usr/local/www/data-dist/form.php on line 38
Then your class form probably does not have a function named form...
In fact, if it does, then in PHP4 that was the constructor, so you
probably can't use that for ANYTHING other than saying:
new form;
And form() gets called on 'new' and only on 'new'
--
Like Music?
http://l-i-e.com/artists.htm
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php