0

I've been given a school project which involves creating an online invoicing system in PHP. My teacher seems to be convinced that the only way to have a menu (with fixed pages like "display", etc) is to use case statements. My first guess would have been to just use a function which echo's some hrefs.

He also keeps saying that PHP is event driven. Is this true? I was always thought the interpreter on the server went through the code and then sent the html to the browser.

Any ideas?

NullPoiиteя
  • 56,591
  • 22
  • 125
  • 143
Edward
  • 95
  • 1
  • 1
  • 9

1 Answers1

0

PHP isn't event driven at all. Altho it exists Photon that is a framework to achive that.
And there are multiple ways to have menu. If with case you mean switch ... case: the answer is no. It is not the only way.

The way I make menu is with an array

$menu = array(
   'url 1'=>'Element 1 ',
   'url 2'=>'Element 2 ',
   'url 3'=>'Element 3 ' 
);

With this array knowing which is the element selected is pretty simple with no need of a case statement

dynamic
  • 46,985
  • 55
  • 154
  • 231
  • That's what I thought. I did mean case. What would you do for the menu structure? – Edward Nov 18 '12 at 18:17
  • @Edward: updated... Alto I didn't consider for hierarchical items. But it's not that hard to innest array from there – dynamic Nov 18 '12 at 18:19