Wednesday 15 January 2014

request - PHP - Do an else to many ifs? -


Edit: Very simple, understand it, just keep it first and none and that Will work for both the ifs.

Well I have written this code and it works fine

  if ($ _ request [pag ']) {// variations by $$ = $ _REQUEST ['Pug']; // POSSIVE PASSWISE PAGES if ($ PAG == "registrar") {include "inc / register.php"; } If ($ pag == "Receipt") (Include {"inc / recover.php"}}   

But if the user type pag = ofksaofkoasdkfkopsd ?

The page will not exist, so I want to include it, if this happens then what is the method to create a file without using it or using something?

You can do this and then the better way would be if

switch statement IF on the same expression Statement of statement In the same way, in many occasions, you may want to compare the same variable (or expression) with many different values, and execute a different piece of code on which it is equal. (.)

  switch ($ _ request ['pug']) {case "registrar": include "inc / register.php"; breakage; case: " Recuper ": included" inc / recover.php "; break; default: // by default you want to include the break;}   

Hope you know about the complexity of the code and in your case switch case there is less complexity in poor / average case

No comments:

Post a Comment