Presentation is loading. Please wait.

Presentation is loading. Please wait.

Web Systems Development (CSC-215)

Similar presentations


Presentation on theme: "Web Systems Development (CSC-215)"— Presentation transcript:

1 Web Systems Development (CSC-215)
Lecture 4: Functions and Objects Monday 12th February 2018

2 Class Test 1 Monday 19th February
Lab based – bring laptops or have desktop ready Lectures 1-6 Duration: 30 minutes

3 Setting up netbeans with wampserver for debugging

4

5

6

7

8

9

10

11 A note on type casting

12 Implicit & Explicit Casting
PHP is loosely typed Variable and its type is declared simply by using it Automatically converts types when needed, via implicit casting

13 What if this behavior causes problems in some situations?
We need a way to override. What if this behavior causes problems in some situations?

14 Explicit Casting Script produces a float value (attempts to produce the most accurate result) What if you need an integer value?

15 Explicit Casting

16 PHP Cast Types

17 Php functions & objects

18 Defining a Function

19 Example: Cleaning up a full name

20 Returning an array

21 Passing by reference

22 Including & requiring files

23 Include Statement

24 Include Once

25 Require and require once
Program continues to execute even if the include failed (will then fail where it was needed)

26 Check if function exists
Because PHP is evolving rapidly

27 Php objects

28 Creating Objects

29 Accessing Objects

30 Cloning Objects Assigning will create an additional reference

31 Not working

32 Use clone to create new instances

33 Constructors

34 Destructors

35 This

36 Static methods Called on class, not object

37 Implicit property definition - allowed by PHP but bad programming practice

38 Constants in class

39 Property & Method Scope
Public Outside code accesses Extending classes should inherit Protected Outside code should not access Private Extending classes should not inherit

40 Usage

41

42 Inheritance Deriving subclasses from pre-existing classes
Only modify the parts that are different Using extends operator

43

44

45

46 The parent operator A method in a subclass with the same name as one in its parent class will override the parent class method The parent operator can be used to access the parent method if this behavior is not desired

47

48 Parent constructors must be called explicitly when needed

49 Prevent overriding by subclass

50 Lecture content adapted from chapter 5 of Learning PHP, MySQL, JavaScript, CSS & HTML5, 3rd Edition, by Robin Nixon.


Download ppt "Web Systems Development (CSC-215)"

Similar presentations


Ads by Google