LauraBokkers / educom-webshop-basis

0 stars 0 forks source link

Maak een functie om een menu item te tonen #18

Open JeroenHeemskerk opened 1 year ago

JeroenHeemskerk commented 1 year ago

In de code hieronder zie je veel herhaling van de <li><a> tags https://github.com/LauraBokkers/educom-webshop-basis/blob/8a93866d8b26b52cf06527360f0ed95c67331834/index.php#L94-L107 Dit is niet D.R.Y. Don't Repeat Yourself

Beter is het om een functie te maken die twee variabelen neemt, bijv. showMenuItem($linkName, $buttonText);

zodat je kan doen:

 function showMenu() 
 { 
     echo '<nav> 
           <ul class="menu">';
     showMenuItem('home', 'HOME');
     showMenuItem('about', 'ABOUT');
     /* ... */
     echo ' </ul> 
         </nav>';  
 }