PHP-language, conditional statements

Slides:



Advertisements
Similar presentations
Chapter 2 Flow of Control. Copyright © 2006 Pearson Addison-Wesley. All rights reserved. 2-2 Learning Objectives Boolean Expressions Building, Evaluating.
Advertisements

Chapter 4 - Control Statements
Internet Application Development tMyn1 INTERNET APPLICATION DEVELOPMENT Timo Mynttinen Mikkelin University of Applied Sciences.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 4: Control Structures I (Selection)
Outline IS400: Development of Business Applications on the Internet Fall 2004 Instructor: Dr. Boris Jukic JavaScript: Control Structure.
Tutorial 4 Decision Making with Control Structures and Statements Section A - Decision Making JavaScript Tutorial 4 -Decision Making with Control.
Java Programming: From Problem Analysis to Program Design, 4e Chapter 4 Control Structures I: Selection.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Control Structures, Operators, and Functions.
Python Control Flow statements There are three control flow statements in Python - if, for and while.
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.
Using Java MINISTRY OF EDUCATION & HIGHER EDUCATION COLLEGE OF SCIENCE AND TECHNOLOGY KHANYOUNIS- PALESTINE Lecture 7 Decision Making : selection statements.
Chapter 4: Control Structures I J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design,
Chapter 4: Control Structures I
Java Programming Constructs 3 MIS 3023 Business Programming Concepts II The University of Tulsa Professor: Akhilesh Bajaj All slides in this presentation.
PROBLEM SOLVING & ALGORITHMS CHAPTER 5: CONTROL STRUCTURES - SELECTION.
 Learn about control structures  Examine relational and logical operators  Explore how to form and evaluate logical (Boolean) expressions  Learn how.
Control Structures 1. Control Structures Java Programming: From Problem Analysis to Program Design, D.S. Malik 2.
PHP-language, conditional statements Teppo Räisänen Principal Lecturer Oulu University of Applied Sciences School of Business and Information Management.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Lecture 2 Control Structure. Relational Operators -- From the previous lecture Relational Operator Meaning == is equal to < is less than > is greater.
Python Mini-Course University of Oklahoma Department of Psychology Day 2 – Lesson 7 Conditionals and Loops 4/18/09 Python Mini-Course: Day 2 - Lesson 7.
PHP Teppo Räisänen LIIKE/OAMK PHP PHP is a programming language for making dynamic and interactive Web pages.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Review if imag(x) > 0 fprintf('Sorry, but I don''t understand complex numbers.\n'); return end if x < 10 % leave this out, type the next line first, and.
Java Programming: From Problem Analysis to Program Design, 3e Chapter 4 Control Structures I: Selection.
1 Chapter 3: Loops and Logic. 2 Control Statements If statement Example NumberCheck.java Relational operators (, >=, ==, !=) Using code blocks with If.
SELF STUDY. IF STATEMENTS SELECTION STRUCTURE if selection statement if … else selection statement switch selection statement.
Programming Fundamentals by Dr. Nadia Y. Yousif1 Control Structures (Selections) Topics to cover here: Selection statements in the algorithmic language:
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.
4 - Conditional Control Structures CHAPTER 4. Introduction A Program is usually not limited to a linear sequence of instructions. In real life, a programme.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
LECTURE # 7 : STRUCTURED PROGRAMMING Selection Statements Tr.Hadeel.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
Chapter 9 Repetition.
Chapter 4: Control Structures I
PHP-language, functions
Course Outcomes of Programming In C (PIC) (17212, C203):
© 2016, Mike Murach & Associates, Inc.
Development of Web Applications - Introduction
Making Choices with if Statements
Chapter 4: Control Structures I
Development of Web Applications – Introduction revisited
PHP-language, loops Jouni Juntunen Oulu University of Applied Sciences
Selection—Making Decisions
CSC113: Computer Programming (Theory = 03, Lab = 01)
The order in which statements are executed is called the flow of control. Most of the time, a running program starts at the first programming statement,
Mobile applications Jouni Juntunen Oulu University of Applied Sciences
PHP-language Variables, assingment and arithmetic operations
Lecturer CS & IT Department UOS MBDIN
Topics discussed in this section:
PHP-language, database-programming
Chapter 5 Repetition.
Chapter 4: Control Structures I
More Selections BIS1523 – Lecture 9.
Topics discussed in this section:
الكلية الجامعية للعلوم التطبيقية
ICS 3U Tuesday, September 21st.
Chapter 9 Control Structures.
Three Special Structures – Case, Do While, and Do Until
Self study.
Visual Basic – Decision Statements
© 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Computer Science Core Concepts
Chapter 4: Control Structures I (Selection)
Program Flow.
CHAPTER 5: Control Flow Tools (if statement)
CS150 Introduction to Computer Science 1
PHP CONDITIONAL STATEMENTS
Flow of Control Flow of control is the order in which a program performs actions. Up to this point, the order has been sequential. A branching statement.
Lecture 9: Implementing Complex Logic
Presentation transcript:

PHP-language, conditional statements Jouni Juntunen Oulu University of Applied Sciences School of Business and Information Management

Control structures Conditional structures Loops Functions If Switch Loops While For Functions http://us.php.net/manual/en/language.control-structures.php

Basic syntax if (expression) { ... } else

Comparison operators

Example <? //Read value passed from HTML-form. $age=$_POST[’age’]; //Found out if user is minor or adult according to age. if ($age<18) { print ”Minor”; } else print ”Adult”; ?>

Nested statements <? $grade=$_POST[’grade’]; If ($grade==0) { print ”F”; } else if ($grade<3) print ”C”; if ($grade<5) print ”B”; if ($gade==5) print ”A”; print ”Not on scale”; ?>

Logical operations || OR && AND ! NOT

Example <? $grade=$_POST[’grade’]; //If grade is not between 0 and 5 it is //not on scale. If ($grade<0 || $grade>5) { print ”Not on scale”; } ?>

Switch Sometimes you can replace multiple if-statements with switch statement Also logical and comparison operators are allowed

Exercises http://www.oamk.fi/~jjuntune/php/exercises.php Exercises 6 to 10 are about conditional statements