php - More efficient way of performing multiple IFs -


There is just one simple test to see which grade grade is for the output. Is there a faster and more efficient way to achieve the objective?

  if ($ grade> = 90) {echo "A"; } Otherwise ($ grade> = 80) {echo "B"; } Otherwise ($ grade> = 70) {echo "C"; } Else {echo "unsuccessful." }  

This is not answering your actual question, but I think that You are making a mistake here:

While using PHP you should not really think about efficiency, it is not a language designed for speed, but easy to use Was designed for. Even more if your application has not yet expired and you have not verified that this piece of code slows down your entire application (for example, using Profiler).


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -