CSCI 297 Scripting Languages Day Seven

Slides:



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

Web Programming Language Week 6 Dr. Ken Cosh PHP Functions & Objects.
C++ Classes & Data Abstraction
PACS – 10/19/131 Object-Oriented Programming “Object-oriented programming opens the door to cleaner designs, easier maintenance, and greater code reuseability.”
Chapter 9 – Inheritance Big Java by Cay Horstmann Copyright © 2009 by John Wiley & Sons. All rights reserved.
Object-Oriented PHP (1)
CSM-Java Programming-I Spring,2005 Fundamental Data Types Lesson - 2.
Inheritance Part III. Lecture Objectives To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke.
What is UML? A modeling language standardized by the OMG (Object Management Group), and widely used in OO analysis and design A modeling language is a.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
Nikolay Kostov Telerik Corporation
PHP Workshop ‹#› PHP Classes and Object Orientation.
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
Inheritance using Java
UFCEUS-20-2 : Web Programming Lecture 5 : Object Oriented PHP (1)
Programming Languages and Paradigms Object-Oriented Programming.
Objectives In this chapter, you will:
Design patterns. What is a design pattern? Christopher Alexander: «The pattern describes a problem which again and again occurs in the work, as well as.
Martin Kruliš This is an Object Oriented system. If we change something, the users object by Martin Kruliš (v1.0)1.
Object Oriented Programming in PHP. Topics Quick OOP Review Classes Magic Methods Static Methods Inheritance Exceptions Interfaces Operators Type Hinting.
CSCI-383 Object-Oriented Programming & Design Lecture 14.
Object-Oriented PHP (Chapter 6).
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
OOP IN PHP `Object Oriented Programming in any language is the use of objects to represent functional parts of an application and real life entities. For.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 07.
PHP - Basic Language Constructs CSCI 297 Scripting Languages - Day Two.
Object Oriented Programming Lecture 5: BallWorld.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
Object-Oriented Programming. An object is anything that can be represented by data in a computer’s memory and manipulated by a computer program.
PHP extras Some advance elements not required in the project.
 Classes in c++ Presentation Topic  A collection of objects with same properties and functions is known as class. A class is used to define the characteristics.
Date : 02/03/2014 Web Technology Solutions Class: OOP PHP, Design Patterns and CRUD.
2010/11 : [1]Building Web Applications using MySQL and PHP (W1)OO PHP PHP Classes and Object Orientation.
CHAPTER 11 INHERITANCE. CHAPTER GOALS To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
Inherited Classes in Java CSCI 392 Ch 6 in O’Reilly Adapted from Dannelly.
1Introduction to PHP 5 Presented by Brett Buddin.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Classes in PHP Web Engineering. What is Class? A class is a collection of variables and functions working with these variables. Variables are defined.
21. PHP Classes To define a class, use the keyword class followed by the name and a block with the properties and method definitions Properties are declared.
Learning OOP in PHP. What is OOP? OOP stands for Object Oriented Programming. OOP is a programming paradigm wherein you create “objects” to work with.
Chapter 10 Developing Object-Oriented PHP. 2 Objectives In this chapter, you will: Study object-oriented programming concepts Use objects in PHP scripts.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
 We have created our two separate 'person' objects, we can set their properties using the methods (the setters) we created.  class person {  var $name;
Classes CSCI 201L Jeffrey Miller, Ph.D. HTTP :// WWW - SCF. USC. EDU /~ CSCI 201 USC CSCI 201L.
Inheritance INHERITANCE: extend existing classes by adding or redefining methods, and adding instance fields Suppose we have a class Vehicle: public class.
15 – PHP(5) Informatics Department Parahyangan Catholic University.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
External Scope CECS 277 Mimi Opkins.
OOP: Encapsulation &Abstraction
Objects as a programming concept
Advance OOP in PHP.
PHP Classes and Objects
Chapter 11 Developing Object-Oriented PHP PHP Programming with MySQL Revised by A. Philipp – Spring 2010 (Rev SP’11)
Web Systems Development (CSC-215)
PHP Classes and Object Orientation
Simple Classes in C# CSCI 293 September 12, 2005.
Classes & Objects: Examples
د.سناء الصايغ الفصل الأول البرمجة الشيئية
Inherited Classes in Java
Singleton design pattern
Simple Classes in Java CSCI 392 Classes – Part 1.
Object-Oriented Programming in PHP
Software Engineering for Internet Applications
Intro to Classes in AutoHotkey
Test123 blah. hjghgghhg.
Object-Oriented PHP (1)
More on PHP: Objects and Sessions Autumn 2015
Classes and Objects Imran Rashid CTO at ManiWeber Technologies.
Hypertext Preprocessor
Presentation transcript:

CSCI 297 Scripting Languages Day Seven Objects in PHP CSCI 297 Scripting Languages Day Seven

Declaring a Class and an Instance <?php class User { public $name, $passwd, $balance; blah blah blah } $X = new User; print_r ($X); User Object ( [name] => [passwd] => [balance] => )

Copying Instances $X = new User; $Y = $X; $X->name = "Bob"; $Y->name = "Sue" echo $X->name . "<br>"; echo $Y->name . "<br>"; $Y = clone $X; Sue

Accessing Public Properties and Public Functions $X->name = "Bob Smith"; $X->balance = 0.0; ================== $amt_due = $X->get_balance(); $X->set_balance(99.99);

Declaring Methods function get_balance() { return $this->balance; } function set_balance ($param) $this->balance = $param;

Declaring Properties 1 of 3 Legal, but VERY bad idea class User {} // that's legal!!! $X = new User; $X->name = "Sue"; // now X has a new property

Declaring Properties 2 of 3 class User { var $name; // name is public public $balance; private $passwd; protected $something; }

Declaring Properties 3 of 3 class User { static $static_property; ... =================== $X = new User; $X->static_property = "Bob"; // illegal User::static_property = "Bob"; // legal

Constructors & Destructors class User { function _construct() $this->balance = 0.0; } function _destruct() blah blah

Subclasses class Customer extends User { function _construct() parent::_construct(); }