1 Pertemuan 14 PHP: Conditions-loops-functions-Array Last Updated: 23 rd May 2011 By M. Arief

Slides:



Advertisements
Similar presentations
Switch code for Lab 4.2 switch (input) { /* input is a variable that we will test. */ case 'M': printf("The prefix is equal to 1E6.\n"); break; case 'k':
Advertisements

If Statements, Try Catch and Validation. The main statement used in C# for making decisions depending on different conditions is called the If statement.
Pertemuan 12.  Create an array  For...In Statement  Join two arrays - concat()  Put array elements into a string - join()  Literal array - sort()
Playing computer with logic problems Please use speaker notes for additional information!
The conditional statement
The Foundation: Logic Propositional Logic, Propositional Equivalence Muhammad Arief download dari
Fundamental Programming Structures in Java: Control Flow, Arrays and Vectors.
Microsoft Visual Basic 2005: Reloaded Second Edition Chapter 4 Making Decisions in a Program.
Internet Application Development tMyn1 INTERNET APPLICATION DEVELOPMENT Timo Mynttinen Mikkelin University of Applied Sciences.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
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.
1 CS101 Introduction to Computing Lecture 23 Flow Control & Loops (Web Development Lecture 8)
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Angela Des Jardins.
1 Controlling Script Flow! David Lash Chapter 3 Conditional Statements.
Week 10 Recap CSE 115 Spring For-each loop When we have a collection and want to do something to all elements of that collection we use the for-each.
Basic Elements of Programming A VB program is built from statements, statements from expressions, expressions from operators and operands, and operands.
Website Development Introducing PHP The PHP scripting language Syntax derives from C, Java and Perl Open Source Links to MySql database.
PHP Server-side Programming. PHP  PHP stands for PHP: Hypertext Preprocessor  PHP is interpreted  PHP code is embedded into HTML code  interpreter.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Control Structures, Operators, and Functions.
IDK0040 Võrgurakendused I harjutus 07: PHP: Operators, Switch, Forms Deniss Kumlander.
Unit 5 – “Watch Out!”. Introduction New Topics Case Structures New Functions Less? Comparison Function Ultrasonic Sensor.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
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.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Slide 3-1 CHAPTER 3 Conditional Statements Objectives To learn to use conditional test statements to compare numerical and string data values To learn.
Slide 1 PHP Operators and Control Structures ITWA 133.
Class 2Intro to Databases Goals of this class Include & Require in PHP Generating Random Numbers in PHP Arrays – Numerically Indexed and Associative Program.
PHP Logic. Review: Variables Variables: a symbol or name that stands for a value – Data types ( Similar to C++ or Java): Int, Float, Boolean, String,
1 Module 3 Conditional Statements. Objectives  Conditional test statements to compare numerical and string data values  Looping statements to repeat.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
ㅎㅎ logical operator if if else switch while do while for Third step for Learning C++ Programming Repetition Control Structures.
CS-3432 Electronic Commerce Lecture – 13 Sikandar Shujah Toor
IDL Tutorials: Day 4 Goal: Learn some programming techniques: Relational operators, conditional statements, boolean operators, loops Maria Kazachenko
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
CST336, Dr. Krzysztof Pietroszek Week 2: PHP. 1.Introduction to PHP 2.Embed PHP code into an HTML web page 3.Generate (output HTML) web page using PHP.
Expressions and Control Flow. Expressions An expression is a combination of values, variables, operators, and functions that results in a value y = 3(abs(2x)
Chapter 7: The Repetition Structure Introduction to Programming with C++ Fourth Edition.
C Language 1 Program Looping. C Language2 Topics Program looping Program looping Relational operators / expressions Relational operators / expressions.
USING CONDITIONAL CODE AMIR KHANZADA. Conditional Statement  Conditional statements are the set of commands used to perform different actions based on.
Copyright © 2003 Pearson Education, Inc. Slide 3-1 The Web Wizard’s Guide to PHP by David A. Lash.
Class07 PHP: loops and includes MIS 3501, Fall 2015 Brad Greenwood, PhD MBA Department of MIS Fox School of Business Temple University 9/15/2015.
For Loops & Arrays. my_rect_pink_mc.width = 40 my_rect_pink_mc.alpha =.5 trace my_rect_pink_mc.x= 20 my_rect_pink_mc.y= 20 for (var i:int = 0; i < 250;
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Control Structure  What is control Structure?  Types of Controls  Use the control structure in VBScript.  Example Summery.
IST 210: PHP Logic IST 210: Organization of Data IST2101.
>> Fundamental Concepts in PHP
CHAPTER 4 DECISIONS & LOOPS
Conditional Statements and Control Structure
Sequence, Selection, Iteration The IF Statement
Comparison Operators Relational Operators.
Announcements Quiz 1 Posted on blackboard
Class07 PHP: loops and includes
3rd prep. – 2nd Term MOE Book Questions.
3rd prep. – 2nd Term MOE Book Questions.
C# Basics These slides are designed for Game Design Class
The Web Wizard’s Guide to PHP
Chapter (3) - Looping Questions.
Class07 PHP: loops MIS 3501 Jeremy Shafer Department of MIS
Logical Operations In Matlab.
Visual Basic – Decision Statements
Intro to Programming CURIE 2011.
Differences between Java and JavaScript
Computer Science Core Concepts
Conditional Logic Presentation Name Course Name
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.
How to allow the program to know when to stop a loop.
Lesson 3. Controlling program flow. Loops. Methods. Arrays.
Presentation transcript:

1 Pertemuan 14 PHP: Conditions-loops-functions-Array Last Updated: 23 rd May 2011 By M. Arief

2 Objectives ► To learn to use logical test operators to create compound conditional test statements ► To learn to use conditional test statements to compare numerical and string data values ► To learn to use looping statements to repeat other statements ► To learn to use several PHP functions useful for Web application development ► To learn to write and use your own functions

3 IF-Statements if (some test) { // code here } else if (some other test) { // code here } else { // if neither test met, do this }

4 Comparison Operator == Equals > Greater than < Less than >= Greater or equal to <= Less or equal to !=, <> Not equal

5 Logical Operator ! NOT !$b Returns true if $b is false && AND $a && $b Returns true if both $a and $b are true || OR $a || $b Returns true if either $a or $b or both are true and AND $a and $b Same as && or OR $a or $b Same as ||

6 SWITCH-Conditionals

7 SWITCH-Conditionals

8 PHP Loops ► Loops provide a mechanism for executing a section of code repeatedly. ► PHP supports four kinds of loops: for, while, do-while and foreach for, while, do-while and foreach

9 FOR-loop

10 WHILE-loop

11 DO-WHILE-loop

12 FOREACH-Loop ► Used extensively to grab and manipulate values from arrays. ► We'll cover this control structure in depth next session with Arrays.

13 PHP Function

14 PHP Function date(), time(), empty

15 PHP Function

16 PHP Function: Return Value

17 PHP Function: Return Value

18 Creating an Array

19 Creating an Array

20 Creating an Array

21 Creating an Array

22 View Array Structure

23 View More Array Details

24 Add Items to an Array

25 Be Careful

26 Delete an Array Element

27 Merge and Count

28 FOREACH and Array

29 FOREACH and Array

30 Implode: from Array to String

31 Explode: from String to Array

32 Array Search

33 Multidimensional Array

34 Multidimensional Array

35 Pertemuan 14 Session Last Updated: 23 rd May 2010 By M. Arief

36 Objectives ► To understand sessions and basic session functionality ► To learn how to use sessions to build multiple page sites with state preservation ► To learn how to use browser cookies to track data about the user ► To learn how to use PHP session handling functions to track various data ► To learn how to declare and use classes

37 HTTP Limitations

38 Chaining Variables in URL’s

39 The Session Solution

40 Sessions

41 How PHP Sessions Work

42 session_start()

43 Common Error

44 Setting and Accessing Session Value

45 Deleting Session Value

46 Contoh Session1.php <? // start the session session_start(); print "Registrasi Sesi Selesai. "; echo "ID sesi anda adalah ". session_id()." "; $data = "arief"; $_SESSION['name'] = $data; echo " Session Value anda adalah ". $_SESSION['name']. " "; ?> Sessio2.php <? session_start(); echo "ID sesi anda pada halaman ke-2 adalah ". session_id()." "; echo " Session Value anda pada halaman ke-2 adalah ". $_SESSION['name']. " "; ?>