USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.

Slides:



Advertisements
Similar presentations
Decision Structures - If / Else If / Else. Decisions Often we need to make decisions based on information that we receive. Often we need to make decisions.
Advertisements

Chapter 4 - Control Statements
3-1 Chapter 3 Flow of Control (part a - branching)
Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: Moving On..
Chapter 13 Control Structures. Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display Control Structures Conditional.
MONTEGO BAY HIGH SCHOOL INFORMATION TECHNOLOGY THE EXCEL IF FUNCTION.
1 Conditional Statement. 2 Conditional Statements Allow different sets of instructions to be executed depending on truth or falsity of a logical condition.
Python Programming Language
Creating PHP Pages Chapter 7 PHP Decisions Making.
1 PHP Statement Constructs Server Scripting. 5-2 Basic Statement All Statements end in a semicolon. Statements are delimited from the HTML code by enclosing.
PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
1 9/26/08CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
Selection Statements choice of one among several blocks of code Java supports 3 kinds of selection statements: if statement – selects one block or leaves.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
true (any other value but zero) false (zero) expression Statement 2
Lecture 4: Booleans and if-else Statements Yoni Fridman 7/3/01 7/3/01.
1 Conditionals In many cases we want our program to make a decision about whether a piece of code should be executed or not, based on the truth of a condition.
Flow control 1: if-statements (Liang 72-80) if(radius < 0) { System.out.println(“cannot get area: radius below zero”); } else { double area = radius *
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
C++ for Engineers and Scientists Third Edition
1 9/28/07CS150 Introduction to Computer Science 1 Logical Operators and if/else statement.
CIS3931 – Intro to JAVA Lecture Note Set 3 19-May-05.
IDK0040 Võrgurakendused I harjutus 07: PHP: Operators, Switch, Forms Deniss Kumlander.
Decisions, Loops, and Arrays Achmad Arwan, S.Kom.
Python – Making Decisions Lecture 02. Control Structures A program that only has one flow is useful but limited. We can use if statements to make these.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Programming Fundamentals. Today’s lecture Decisions If else …… Switch Conditional Operators Logical Operators.
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
A Program is nothing but the execution of sequence of one or more Instructions. On the basis of application it is essential. To Alter the flow of a program.
Simple Control Structures IF, IF-ELSE statements in C.
MS3304: Week 6 Conditional statements. Overview The flow of control through a script Boolean Logic Conditional & logical operators Basic decision making.
ITM 352 Flow-Control: if and switch. ITM © Port, KazmanFlow-Control - 2 What is "Flow of Control"? Flow of Control is the execution order of instructions.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Slide 1 PHP Operators and Control Structures ITWA 133.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
Syntax : If ( Expression ) If ( Expression ) {Statements; } Example : ?>
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
If…else statements. Boolean Expressions Boolean expression - An expression whose value is either true or false true = 1 false = 0 Datatype: boolean.
Decision making statements. Decision making statements are used to skip or to execute a group of statements based on the result of some condition. The.
CMP-MX21: Lecture 4 Selections Steve Hordley. Overview 1. The if-else selection in JAVA 2. More useful JAVA operators 4. Other selection constructs in.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Copyright 2003 Scott/Jones Publishing Making Decisions.
Programming 1 DCT 1033 Control Structures I (Selection) if selection statement If..else double selection statement Switch multiple selection statement.
ENGR 101: Robotics Lecture 4 – Making Decisions Outline  The Stall Sensor  Making Decisions  Random Number Generation References 
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PEG200/Saidatul Rahah 1.  Selection Criteria › if..else statement › relational operators › logical operators  The if-then-else Statement  Nested if.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
The If Statement There are no switch statements in Python. You need to use just if statements. There are no switch statements in Python. You need to use.
IST 210: PHP LOGIC IST 210: Organization of Data IST210 1.
Selection (if-then-else) Programming Has 3 Types of Control: Sequential (normal): Control of Execution Proceeds One after the Other Selection (if-then-else):
IF STATEMENTS AND BOOLEAN EXPRESSIONS. BOOLEAN EXPRESSIONS Evaluate to a value of true or false Use relational or equivalence operators Boolean operators.
 Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do.
C++ for Engineers and Scientists Second Edition Chapter 4 Selection Structures.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Very often when you write code, you want to perform different actions for different decisions. You can use conditional statements in your code to do this.
CHAPTER 4 DECISIONS & LOOPS
Selection (also known as Branching) Jumail Bin Taliba by
Sequence, Selection, Iteration The IF Statement
Struktur Control : Decision
JavaScript Selection Statement Creating Array
Selection CSCE 121 J. Michael Moore.
Visual Basic – Decision Statements
Computer Science Core Concepts
Relational Operators.
There many situations comes in real life when we need to make some decisions and based on these decisions, we decide what should we do next. Similar situations.
PHP CONDITIONAL STATEMENTS
Presentation transcript:

USING CONDITIONAL CODE AMIR KHANZADA

Conditional Statement  Conditional statements are the set of commands used to perform different actions based on different conditions.  In PHP we have the following conditional statements: If Else Else if switch

If Statement  If structure is used for conditional execution of code segment.  If something is true, then do something.  Syntax: if (expr) { Statements }

If Statement  $d) { echo "c is bigger than d"; } ?> In the above example, only if the condition "$c>$d" is true, the message "c is bigger than d" is displayed

CONDITIONAL CODE If( ) { } condition // your additional code goes here //...

TERMINOLOGY parentheses brackets braces ()() {}{} [][]

CONDITIONAL CODE If( ) { } condition echo “it’s true!”; //... $a < 50$b > 20 true or false? $c == 99$c === 99$d != 100 Code block

EQUALITY If( $a == $b ){ // execute this code }

ASSIGNMENT INSTEAD OF EQUALITY $a = 5; $b = 10; If( $a = $b ){ // always true! }

OPERATOR WITH = =assignment ==equality ===strict equality

COMPARISON If( $a == $b ){ … If( $a != $b ){ … If( $a === $b ){ … If( $a !== $b ){ … If( $a > $b ){ … If( $a < $b ){ … If( $a >= $b ){ … If( $a <= $b ){ …

&& LOGICAL AND / OR If( $a === $b $c === $d){… If( ($a > $b) && ($c > $d) ){… and or ||

Else Statement  If you want to execute some code if a condition is true and another code if a condition is false, use the if....else statement.  Syntax if (condition) code to be executed if condition is true; else code to be executed if condition is false;

Else Statement  $d) { echo "C is bigger than d"; } else { echo "D is bigger than c"; } ?> Result: D is bigger than C In the above example in the if the condition "$c>$d" is true then the message "C is bigger than D" is displayed, else the message "D is bigger than C" is displayed.