Marlene,

I am trying to figure out someone else's example to produce code of my own.
In the following code, what is the "createcalendar" in the second line? the
filename of the php document itself? what is case?

=if CASE is confusing you then you need to read the manual. If you have
never heard of CASE before then you need to learn programming. The SWITCH
construct allows evaluation of an expression, in this case the value of
$action, and then conditional execution of the ensuing CASE clauses from the
point where the CASE value, eg "createcalendar", is equal to the CASE
expression. Normally there would be several CASE clauses in a single SWITCH
construct.

=Have you given us all the code, because that's what's strange about this
snippet - it would be easier to think/write:

if ( $action == "createcalendar" )
{
   create_calendar();
}
else
{
      html_header();
      entercalendar_form();
      html_footer();
}
[hacked it, haven't checked it]

=so "createcalendar" is (the) one value which can be used to switch the
activity of the script between different logic paths. As to where it comes
from/relationship to the filename we can't comment, because you haven't
given that information. It seems reasonable that the script is processing
results from some form, and what you say then applies.

=if you have not just inherited someone's code, but have inherited code that
is not yet working (and may God have mercy on your soul !) then it would
seem reasonable that the SWITCH construct has been designed to allow all
sorts of new 'instructions' (from the form) to be processing/programmed, in
future, eg load existing calendar.

The php documentation is not really helping me. I AM GETTING ERROR of
unexpected T variable here.  What am I doing wrong? I will provide more
information if needed, but I don't know what to provide.

switch($action) {
   case "createcalendar":
      create_calendar();
   break;
   default:
      html_header();
      entercalendar_form();
      html_footer();
   break;
}


=As to the syntax error, if this isn't a direct and full copy then we're on
a hiding to nothing anyway. Which line is pointed to? Is it possible that an
earlier brace, parenthesis, or double-quotes pair was not properly closed?

=Regards,
=dn



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

Reply via email to