hi this is Raghu from tutorial dr.com and welcome to PHP video series so in this lecture we will see an example of conditional operators so we have only one conditional operator that is question mark so we will see an example so let’s open our text editor so create a new file so save it as dot PHP let’s say ok so let’s open PHP tag so as I told we have only question mark has conditional operators so what it will do so the the syntax is very simple so just give some condition if the and use the question mark if it is true then you can display something so we will write it as true block if it is false then we can exclude the false block and we can end the statement with semicolon so this is a simple syntax for conditional operators so let’s check or try with an example so similarly like previous examples let’s use a variable X so dollar X is 10 or 20 Y is 30 okay so now use dollar Z so now I want to assign the highest value I assign bigger value to so out of X & Y so whichever is greater I want to assign that value to my Z so I can create a condition like if dollar X is greater than dollar Y if the condition is true so I want to assign the highest value so I can assign dollar X if not I will assign dollar Y it means in both conditions and master I mean the bigger value to Z so if you see it exists greater than Y it means X has the bigger value so I’m assigning this one if this condition is true this block will be executed so that’s why I am assigning X to Z if this condition is false it means Y is bigger so I’m assigning Y to Z or Z so let’s display C value is don’t work it send me calm at the end so let’s open our browser it is not it is conditional okay so we have some error at line eight what is that we not only eight seven and eight you forgot semi columns okay let’s reload the page again yes Z value is 30 because this is the highest value let’s change to 120 and 310 310 because this is the highest well so this how we will use conditional operators and this is very useful we will use this one you know instead of having a big defense room if you want to achieve the same functionality by using if-else loop I’ll tell you what we have to do so we have to great evils loop if X is greater than Y then assign Center equals so here X so tall X and here you have to echo something like will use echo in the end else that values so let me comment this one still we should get the same output 3:10 so yes so both are doing the same work so instead of using these evils you know block so we can just use a simple the conditional operator so that’s what in the beginning I told this is an alternative to if else clock

Tags:






Youtube
Facebook
Google Plus
Twitter
TutorialDrive


Apache Zookeeper Tutorial

Apache Kafka Tutorial

Apache Kafka Security

Elasticserarch n Kibana

Java 8 Tutorial

Log4J Tutorial

Apache Storm Tutorial

SQLite Tutorial

Apache Ant Tutorial

Related Posts

blog

Apache Kafka Commands Cheat sheet

Spread the loveKafka Topics List existing topics bin/kafka-topics.sh –zookeeper localhost:2181 –list Purge a topic bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –config retention.ms=1000 … wait a minute … bin/kafka-topics.sh –zookeeper localhost:2181 –alter –topic mytopic –delete-config retention.ms
Read more…

blog

What is Apache Maven | Apache Maven complete tutorial from scratch pdf

Spread the love In this post you will learn the complete tutorial of Apache Maven build tool What is Maven ? Apache Maven is a software project management and comprehension tool. Based on the concept
Read more…

blog

Practical Guide for Web Development in 2018

Spread the loveWelcome to my practical guide  for web development in 2018 in terms of  technology and career. Before we start I just want to  mention a few things, you don’t need to learn  everything that
Read more…