MCS/BCS.

Slides:



Advertisements
Similar presentations
PHP functions What are Functions? A function structure:
Advertisements

Spring Semester 2013 Lecture 5
Outline What Is Function ? Create Function Call Function Parameters Functions Function Returning Values PHP Variable Scopes Passing by Reference Vs Value.
Functions ROBERT REAVES. Functions  Interface – the formal description of what a subprogram does and how we communicate with it  Encapsulation – Hiding.
PHP Conditions MIS 3501, Fall 2014 Jeremy Shafer Department of MIS Fox School of Business Temple University September 11, 2014.
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
ITC 240: Web Application Programming
Example 2.
Structured programming
IS 1181 IS 118 Introduction to Development Tools VB Chapter 03.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Control Structures, Operators, and Functions.
Intermediate PHP (2) File Input/Output & User Defined Functions.
IE 212: Computational Methods for Industrial Engineering
COMPUTER PROGRAMMING. Functions What is a function? A function is a group of statements that is executed when it is called from some point of the program.
PHP Conditional Statements Conditional statements in PHP are used to perform different actions based on different conditions. Conditional Statements Very.
13/2/12 Lecture 6. Functions 2 types: – Built in functions – Custom defined functions Functions minimize the amount of repetition of code. function consists.
1Computer Sciences Department Princess Nourah bint Abdulrahman University.
PHP Constructs Advance Database Management Systems Lab no.3.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
COMPUTER PROGRAMMING. Functions’ review What is a function? A function is a group of statements that is executed when it is called from some point of.
_______________________________________________________________________________________________________________ PHP Bible, 2 nd Edition1  Wiley and the.
Outline if...else...elseif Statements Switch Loops Functions Arrays Forms.
PHP Function. Outline o What Is Function ? o Create Function o Call Function o Parameters Functions o Function Returning Values o Passing by Reference.
Lecture 2 Conditional Statement. chcslonline.org Conditional Statements in PHP Conditional Statements are used for decision making. Different actions.
PHP. PHP User Defined Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
1 JavaScript Part 3. Functions Allow the user to decide when a particular script should be run by the browser in stead of running as long as the page.
4. Javascript M. Udin Harun Al Rasyid, S.Kom, Ph.D Lab Jaringan Komputer (C-307) Desain.
Functions  A Function is a self contained block of one or more statements or a sub program which is designed for a particular task is called functions.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
Creating PHP Pages Chapter 5 PHP Structure and Syntax.
 A PHP script can be placed anywhere in the document.  A PHP script starts with  The default file extension for PHP files is ".php".  A PHP file normally.
Creating FunctionstMyn1 Creating Functions Function can be divided into two groups: –Internal (built in) functions –User-defined functions.
Programming Fundamentals Enumerations and Functions.
11 – Introduction to PHP(1) Informatics Department Parahyangan Catholic University.
PHP Tutorial. What is PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.
 The real power of PHP comes from its functions; it has more than 1000 built-in functions.  PHP User Defined Functions  Besides the built-in PHP functions,
ITM 3521 ITM 352 Functions. ITM 3522 Functions  A function is a named block of code (i.e. within {}'s) that performs a specific set of statements  It.
 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.
Intro to CS Nov 29, 2016.
PHP using MySQL Database for Web Development (part II)
PHP Built-In Functions
CHAPTER 4 DECISIONS & LOOPS
Functions A function is a block of code with a name. function functionName() { code to be executed; }
PHP 5 Syntax.
CHAPTER 5 SERVER SIDE SCRIPTING
PHP Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in.
4. Javascript Pemrograman Web I Program Studi Teknik Informatika
JavaScript: Functions.
ITM 352 Flow-Control: Loops
PHP Functions, Scope MIS 3501, Fall 2015 Jeremy Shafer
For Loops October 12, 2017.
Introduction to Web programming
Functions A function is a “pre-packaged” block of code written to perform a well-defined task Why? Code sharing and reusability Reduces errors Write and.
PHP.
Objectives In this chapter, you will:
Basics (Cont...).
Tutorial 6 PHP & MySQL Li Xu
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.
COMPUTER PROGRAMMING SKILLS
Functions Imran Rashid CTO at ManiWeber Technologies.
PHP an introduction.
PHP Function and Array 05 CHAPTER Padasalai MOHAMED FAKRUDEEN
ITM 352 Functions.
CPS125.
Corresponds with Chapter 5
 A function is a named sequence of statement(s) that performs a computation. It contains  line of code(s) that are executed sequentially from top.
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
Selamat Datang di “Programming Essentials in Python”
Presentation transcript:

MCS/BCS

PHP User Defined Functions Besides the built-in PHP functions, we can create our own functions. A function is a block of statements that can be used repeatedly in a program. A function will not execute immediately when a page loads. A function will be executed by a call to the function.

Create a User Defined Function in PHP A user-defined function declaration starts with the word function Syntax function functionName() {     code to be executed; } Function names are NOT case-sensitive. <?php function writeMsg() {     echo "Hello world!"; } writeMsg(); // call the function ?>

PHP Function Arguments Information can be passed to functions through arguments. An argument is just like a variable. Arguments are specified after the function name, inside the parentheses. You can add as many arguments as you want, just separate them with a comma. The following example has a function with one argument ($fname). When the familyName() function is called, we also pass along a name (e.g. Ali), and the name is used inside the function, which outputs several different first names, but an equal last name:

Cont… <?php function familyName($fname) {     echo "$fname khan.<br>"; } familyName(“ali"); familyName(“akbar"); familyName(“Amjid"); familyName(“Ahmad"); familyName(“Javeed"); ?>

Cont… Example: <?php function familyName($fname, $year) {     echo "$fname Khan. Born in $year <br>"; } familyName(“Asad", "1975"); familyName(“Akbar", "1978"); familyName(“Ali", "1983"); ?>

PHP Default Argument Value <?php function setHeight($minheight = 50) {     echo "The height is : $minheight <br>"; } setHeight(350); setHeight(); setHeight(135); setHeight(80); ?>

PHP Functions - Returning values <?php function sum($x, $y) {     $z = $x + $y;     return $z; } echo "5 + 10 = " . sum(5, 10) . "<br>"; echo "7 + 13 = " . sum(7, 13) . "<br>"; echo "2 + 4 = " . sum(2, 4); ?>