More PHP…. Understanding Variable Scope The term scope refers to the places within a script where a particular variable is visible. The six basic scope.

Slides:



Advertisements
Similar presentations
CPSC 388 – Compiler Design and Construction
Advertisements

UFCE8V-20-3 Information Systems Development 3 (SHAPE HK) Lecture 3 PHP (2) : Functions, User Defined Functions & Environment Variables.
JavaScript Part for Repetition Statement for statement Cpecifies each of the items needed for counter-controlled repetition with a control variable.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 06.
PHP –Writing Reusable Code 10 March 2006 Adina Crainiceanu IT420: Database Management and Organization.
Javascript Client-side scripting. Up to now  We've seen a little about how to control  content with HTML  presentation with CSS  Javascript is a language.
DT228/3 Web Development JSP: Directives and Scripting elements.
IS 1181 IS 118 Introduction to Development Tools Chapter 5 Reusing Code.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Control Statements II.
1 Chapter 8 Scope, Lifetime, and More on Functions Dale/Weems/Headington.
Scope.
ALBERT WAVERING BOBBY SENG. Week Whatever: PHP  Announcements/questions/complaints.
PHP Tutorials 02 Olarik Surinta Management Information System Faculty of Informatics.
Introduction to PHP and Server Side Technology. Slide 2 PHP History Created in 1995 PHP 5.0 is the current version It’s been around since 2004.
Chapter 4 – The Building Blocks Data Types Literals Variables Constants.
Lab Assignment 7 | Web Forms and Manipulating Strings Interactive Features Added In this assignment you will continue the design and implementation of.
1 Chapter 9 Scope, Lifetime, and More on Functions.
NMED 3850 A Advanced Online Design January 26, 2010 V. Mahadevan.
School of Computing and Information Systems CS 371 Web Application Programming PHP - Basics Serving up web pages.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Copyright © 2012 Addison-Wesley. All rights reserved.1-2 Topics Scope Scope and Lifetime Referencing Environments.
Prof: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015 C Tutorial CIS5027.
Web Design and Development for E-Business By Jensen J. Zhao Copyright 2003 Prentice Hall, Inc. Web Design and Development for E-Business Jensen J. Zhao.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Names and Scope. Scope Suppose that a name is used many times for different entities in text of the program, or in the course of execution. When the name.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Functions.
Hans-Peter Plag November 6, 2014 Session 4 (Programming Languages) (Data Types and Variables) Expressions and Operators Flow Control.
18. DECLARATIONS.
A First Simple Program /* This is a simple Java program. Call this file "Example.java".*/ class Example { // Your program begins with a call to main().
ALBERT WAVERING BOBBY SENG. Week 4: JavaScript  Quiz  Announcements/questions.
THINKING BIG Abstraction and Functions chapter 6 Modified by Dr. Paul Mullins for CPSC 130, F05.
1 PHP Introduction Chapter 1. Syntax and language constructs.
Storing and Retrieving Data
C Functions Three major differences between C and Java functions: –Functions are stand-alone entities, not part of objects they can be defined in a file.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting Files & Directories.
הרצאה 4. עיבוד של דף אינטרנט דינמי מתוך Murach’s PHP and MySQL by Joel Murach and Ray Harris.  דף אינטרנט דינמי משתנה עפ " י הרצת קוד על השרת, יכול להשתנות.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
+ Storage Classes and Linkage. + Introduction Scope describe the region or regions of a program that can access and identifier Variables can be shared.
PHP Reusing Code and Writing Functions 1. Function = a self-contained module of code that: Declares a calling interface – prototype! Performs some task.
Creating FunctionstMyn1 Creating Functions Function can be divided into two groups: –Internal (built in) functions –User-defined functions.
Session 2: PHP Language Basics iNET Academy Open Source Web Development.
Web Page Designing With Dreamweaver MX\Session 1\1 of 9 Session 3 PHP Advanced.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Chapter 7 - Functions. Functions u Code group that performs single task u Specification refers to what goes into and out of function u Design refers to.
1 Chapter 8 Scope, Lifetime, and More on Functions CS185/09 - Introduction to Programming Caldwell College.
JavaScript Variables. Definition A variable is a "container" for information you want to store. A variable's value can change during the script.
Variable Scope. When you declare a variable, that name and value is only “alive” for some parts of the program  We must declare variables before we use.
Databases.
CS 371 Web Application Programming
Storage class in C Topics Automatic variables External variables
JavaScript: Functions
JavaScript: Functions.
PHP Variables A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume) Rules for PHP variables: A variable.
Elements of the PHP Programming Environment
Web Systems Development (CSC-215)
Web Systems Development (CSC-215)
Functions BIS1523 – Lecture 17.
Scope of Variables.
Scope, Visibility, and Lifetime
PHP.
Chapter 20: Programming Functions
JavaScript CS 4640 Programming Languages for Web Applications
PHP: Hypertext Preprocessor
PHP an introduction.
STORAGE CLASS.
The Three Attributes of an Identifier
Web Programming and Design
Storage classes in C In C language, each variable has a storage class which decides the following things: scope i.e where the value of the variable would.
JavaScript CS 4640 Programming Languages for Web Applications
Scope Rules.
Presentation transcript:

More PHP…

Understanding Variable Scope The term scope refers to the places within a script where a particular variable is visible. The six basic scope rules in PHP are as follows: – Built-in superglobal variables are visible everywhere within a script. – Constants, once declared, are always visible globally; that is, they can be used inside and outside functions. – Global variables declared in a script are visible throughout that script, but not inside functions. – Variables inside functions that are declared as global refer to the global variables of the same name. – Variables created inside functions and declared as static are invisible from outside the function but keep their value between one execution of the function and the next. – Variables created inside functions are local to the function and cease to exist when the function terminates.

PHP Simple eCommerce Bob’s Auto Parts… – Retrieve HTTP_POST – Quick sanity check - if ($totalqty == 0) – Date() Function – Conditional Statement – Define() constant variables – Operator Precedence (calc tax rate) Why would this NOT work in an actual business?

PHP while Loops Freight calculator… Static vs dynamic table generation. Which way is better? Why?

PHP Better eCommerce… Same as Simple, BUT… With a flat file we can record orders and view them later. Some rants about flat files – Security! Is the setup that I have currently secure? – PHP File system Functions ( fopen(), flock(), fwrite(), fclose(), fgets(), fgetss(), fgetcsv(), feof()

PHP Better eCommerce What are some of the issues with using a flat file? Is there a time where flat files would be good to use? Is there anything better?

Mid Term Review HTML CSS JavaScript PHP