>> Fundamental Concepts in PHP

Slides:



Advertisements
Similar presentations
Session 1 & 2BBK P1 Module5-May-2007 : [‹#›] PHP: Moving On..
Advertisements

PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
1 CS428 Web Engineering Lecture 19 Data Types (PHP - II)
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)PHP Recap.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Chapter 4: Decision Making with Control Structures and Statements JavaScript - Introductory.
Open Source Software Unit – 3 Presented By Mr. R.Aravindhan.
CONTROL STRUCTURE The if, elseif, and else & switch Statements 1.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Slide 1 PHP Operators and Control Structures ITWA 133.
PHP. What is PHP? PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
Control Structures By Shyam Gurram. Control Structure In this chapter we have two different types of structures. Conditional Structure Iterative Control.
JavaScript Syntax and Semantics. Slide 2 Lecture Overview Core JavaScript Syntax (I will not review every nuance of the language)
PHP Constructs Advance Database Management Systems Lab no.3.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Introduction to PHP.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
IT ELECTIVE 2.  Web server Can refer to either the hardware (the computer) or the software (the computer application) that helps to deliver content that.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
2: Basics Basics Programming C# © 2003 DevelopMentor, Inc. 12/1/2003.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
Learning Javascript From Mr Saem
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.
PHP using MySQL Database for Web Development (part II)
Introduction to Calculated Columns Variables, Conditionals, and String Manipulation PRESENTER: Cameron Blashka| Informer Implementation Specialist| April.
Session 2 Basics of PHP.
Expressions and Control Flow in PHP
>> Introduction to JavaScript
CHAPTER 10 JAVA SCRIPT.
CHAPTER 5 SERVER SIDE SCRIPTING
เอกสารประกอบการบรรยายรายวิชา Web Technology
Tutorial 12 Working with Arrays, Loops, and Conditional Statements
Operators Operators are symbols such as + (addition), - (subtraction), and * (multiplication). Operators do something with values. $foo = 25; $foo – 15;
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Basics of JavaScript Programming Language
JavaScript Syntax and Semantics
PHP Introduction.
Expressions and Control Flow in JavaScript
JavaScript: Control Statements I
String Conversion and Type Juggling
Arrays, For loop While loop Do while loop
Chapter 8 JavaScript: Control Statements, Part 2
During the last lecture we had a discussion on Data Types, Variables & Operators
PHP.
T. Jumana Abu Shmais – AOU - Riyadh
3 Control Statements:.
HYPERTEXT PREPROCESSOR BY : UMA KAKKAR
Web Programming Language
Chapter 3: Selection Structures: Making Decisions
Boolean Expressions to Make Comparisons
Chapter 3: Selection Structures: Making Decisions
PHP an introduction.
Web Programming– UFCFB Lecture 13
CIS 136 Building Mobile Apps
Algoritma & Pemrograman 1
Web Programming and Design
This is an introduction to JavaScript using the examples found at the CIS17 website. In previous examples I specified language = Javascript, instead of.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Chapter 8 JavaScript: Control Statements, Part 2
Intro to Programming (in JavaScript)
Contact PSK Technologies Pvt. Ltd IT Company Address - Plot No-780, Near Durga Temple, Katol Road Chaoni, Nagpur-13.
Presentation transcript:

>> Fundamental Concepts in PHP

Variables Variable In PHP An entity that can hold a value Variable Names start with “$” sign Assignment operator is the same “=“ Must begin with a letter or an underscore (_) Must contain only alpha-numeric values and underscore No Spaces Case-sensitive NAMING RULES TRY NOW Create a variable called name and add your name as the value

Strings Strings PHP Like JavaScript, PHP also uses strings String concatenation is done using “.” (unlike JavaScript where we use the “+” operator) Provides a number of string processing functions echo $txt1 . " " . $txt2; http://devdocs.io/php-string/

Greater than or equal to Operators Inc / Dec Operator Name ++ x Pre-increment x ++ Post-increment -- x Pre-decrement x -- Post-decrement Comparison Arithmetic Operator Name x + y Addition x - y Subtraction x * y Multiplication x / y Division x % y Modulus Operator Name x == y Equal x === y Identical x != y Not equal x <> y x !== y Not identical x > y Greater than x < y Less than x >= y Greater than or equal to x <= y Less than or equal to Logical Operator Name x and y And x or y Or x xor y Xor x && y x || y ! x Not

Conditional Conditionals PHP Provides a way to have certain commands executed only if some condition is met PHP If statement If…..Else statement Switch statement

IF Conditional If statement TRY NOW SYNTAX Create a variable password { } SYNTAX Create a variable password Initialize it with a value “p@ssw0rd” Now check if the password is equal to “p@ssw0rd” If true, Echo “Welcome” TRY NOW

IF-Else Conditional If-Else statement TRY NOW SYNTAX if(cond) { } else SYNTAX Now add an else statement to the previous statement If the password is not correct then echo “You are in the wrong neighborhood” TRY NOW

Complex Conditional If-Else statement with Complex Conditional TRY NOW if(cond) { } else SYNTAX Now add another variable called username and initialize to a value called “labuser”. Now change the if condition to check if username is equal to “labuser” and password is equal to “p@ssw0rd” TRY NOW

Switch Conditional Switch statement TRY NOW SYNTAX switch (n) { case label1:    code to be executed if n=label1;    break; ……… default: } SYNTAX TRY NOW Create and initialize a variable called item. Then switch the variable If item is eggs then echo “SAR 3.65” If item is milk then echo “SAR 5.00” Else echo out “SAR 0.00”

Loops Looping Provides a way to have certain block of commands to be executed again and again for certain number of times PHP While Loop Do….While Loop For Loop ForEach

While Loop While statement TRY NOW SYNTAX while(cond) { } SYNTAX Use the while loop to repeat some text 10 times TRY NOW

Do-While Loop Do-While statement At least runs the loop once TRY NOW { } while(cond); SYNTAX At least runs the loop once Repeat the previous exercise using do-while loops instead. TRY NOW

For Loop For Loop TRY NOW HINT: SYNTAX Create an array for(init; cond; increment) { } SYNTAX Create an array Display its elements using the for-loop TRY NOW HINT: Use count() to get the length of the array

Functions in PHP Functions Group Block of Code Reusable Code TRY NOW function name(paramters) { return value; } SYNTAX Separate by comma Use “$” sign Create a function add() which takes two parameters and returns the result which is the sum of the two numbers. TRY NOW

Important String Functions Length: strlen(‘string’); Substring: mb_substr(‘string’, start, length); Break string into array: explode(break-char, ‘string’); Join: implode(array-name, join-char); Reverse: strrev(‘string’); To Upper Case: strtoupper(‘string’); To Lower Case: strtolower(‘STRING’); Times Occurance: substr_count(‘My My’,’sub-string’);

Web-Based Systems - Misbhauddin Next on PHP Integrating PHP with HTML Reusing PHP Files Web-Based Systems - Misbhauddin

Web-based Systems | Misbhauddin Mini-PHP Project Mini Course Project Build an e-commerce website “Buy 4m Me” Listing all items you want to sell through the online store Customers can view and select the items Customers can add them to their cart Customer can checkout and make payment Confirmation Emails Web-based Systems | Misbhauddin