Presentation is loading. Please wait.

Presentation is loading. Please wait.

 2008 Pearson Education, Inc. All rights reserved. 1 23 PHP.

Similar presentations


Presentation on theme: " 2008 Pearson Education, Inc. All rights reserved. 1 23 PHP."— Presentation transcript:

1  2008 Pearson Education, Inc. All rights reserved. 1 23 PHP

2  2008 Pearson Education, Inc. All rights reserved. 2 Conversion for me was not a Damascus Road experience. I slowly moved into a intellectual acceptance of what my intuition had always known. — Madeleine L’Engle Be careful when reading health books; you may die of a misprint. — Mark Twain

3  2008 Pearson Education, Inc. All rights reserved. 3 Reckoners without their host must reckon twice. — John Heywood There was a door to which I found no key; There was the veil through which I might not see. — Omar Khayyam

4  2008 Pearson Education, Inc. All rights reserved. 4 OBJECTIVES In this chapter you will learn:  To manipulate data of various types.  To use operators, arrays and control statements.  To use regular expressions to search for patterns.  To construct programs that process form data.  To store data on the client using cookies.  To create programs that interact with MySQL databases.

5  2008 Pearson Education, Inc. All rights reserved. 5 23.1Introduction 23.2 PHP Basics 23.3 String Processing and Regular Expressions 23.3.1 Comparing Strings 23.3.2 Regular Expressions 23.4 Form Processing and Business Logic 23.5 Connecting to a Database 23.6 Using Cookies 23.7 Dynamic Content 23.8 Operator Precedence Chart 23.9 Wrap-Up 23.10 Web Resources

6  2008 Pearson Education, Inc. All rights reserved. 6 Outline first.php

7  2008 Pearson Education, Inc. All rights reserved. 7 Common Programming Error 23.1 Failing to precede a variable name with a $ is a syntax error.

8  2008 Pearson Education, Inc. All rights reserved. 8 Common Programming Error 23.2 Variable names in PHP are case sensitive. Failure to use the proper mixture of cases to refer to a variable will result in a logic error, since the script will create a new variable for any name it doesn’t recognize as a previously used variable.

9  2008 Pearson Education, Inc. All rights reserved. 9 Common Programming Error 23.3 Forgetting to terminate a statement with a semicolon ( ; ) is a syntax error.

10  2008 Pearson Education, Inc. All rights reserved. 10 Fig. 23.2 | PHP types.

11  2008 Pearson Education, Inc. All rights reserved. 11 Outline data.php (1 of 3)

12  2008 Pearson Education, Inc. All rights reserved. 12 Outline data.php (2 of 3)

13  2008 Pearson Education, Inc. All rights reserved. 13 Outline data.php (3 of 3)

14  2008 Pearson Education, Inc. All rights reserved. 14 Error-Prevention Tip 23.1 Function print can be used to display the value of a variable at a particular point during a program’s execution. This is often helpful in debugging a script.

15  2008 Pearson Education, Inc. All rights reserved. 15 Common Programming Error 23.4 Assigning a value to a constant after it is declared is a syntax error.

16  2008 Pearson Education, Inc. All rights reserved. 16 Outline operators.php (1 of 3)

17  2008 Pearson Education, Inc. All rights reserved. 17 Outline operators.php (2 of 3)

18  2008 Pearson Education, Inc. All rights reserved. 18 Outline operators.php (3 of 3)

19  2008 Pearson Education, Inc. All rights reserved. 19 Error-Prevention Tip 23.2 Initialize variables before they are used to avoid subtle errors. For example, multiplying a number by an uninitialized variable results in 0.

20  2008 Pearson Education, Inc. All rights reserved. 20 Fig. 23.5 | PHP keywords.

21  2008 Pearson Education, Inc. All rights reserved. 21 Outline arrays.php (1 of 4)

22  2008 Pearson Education, Inc. All rights reserved. 22 Outline arrays.php (2 of 4)

23  2008 Pearson Education, Inc. All rights reserved. 23 Outline arrays.php (3 of 4)

24  2008 Pearson Education, Inc. All rights reserved. 24 Outline arrays.php (4 of 4)

25  2008 Pearson Education, Inc. All rights reserved. 25 Outline compare.php (1 of 2)

26  2008 Pearson Education, Inc. All rights reserved. 26 Outline compare.php (2 of 2)

27  2008 Pearson Education, Inc. All rights reserved. 27 Outline expression.php (1 of 2)

28  2008 Pearson Education, Inc. All rights reserved. 28 Outline expression.php (2 of 2)

29  2008 Pearson Education, Inc. All rights reserved. 29 Fig. 23.9 | Some PHP quantifiers.

30  2008 Pearson Education, Inc. All rights reserved. 30 Fig. 23.10 | Some PHP character classes.

31  2008 Pearson Education, Inc. All rights reserved. 31 Fig. 23.11 | Some useful superglobal arrays.

32  2008 Pearson Education, Inc. All rights reserved. 32 Outline form.html (1 of 4)

33  2008 Pearson Education, Inc. All rights reserved. 33 Outline form.html (2 of 4)

34  2008 Pearson Education, Inc. All rights reserved. 34 Outline form.html (3 of 4)

35  2008 Pearson Education, Inc. All rights reserved. 35 Outline form.html (4 of 4)

36  2008 Pearson Education, Inc. All rights reserved. 36 Good Programming Practice 23.1 Use meaningful XHTML object names for input fields. This makes PHP scripts that retrieve form data easier to understand.

37  2008 Pearson Education, Inc. All rights reserved. 37 Outline form.php (1 of 5)

38  2008 Pearson Education, Inc. All rights reserved. 38 Outline form.php (2 of 5)

39  2008 Pearson Education, Inc. All rights reserved. 39 Outline form.php (3 of 5)

40  2008 Pearson Education, Inc. All rights reserved. 40 Outline form.php (4 of 5)

41  2008 Pearson Education, Inc. All rights reserved. 41 Outline form.php (5 of 5)

42  2008 Pearson Education, Inc. All rights reserved. 42 Software Engineering Observation 23.1 Use business logic to ensure that invalid information is not stored in databases. When possible, validate important or sensitive form data on the server, since JavaScript may be disabled by the client. Some data, such as passwords, must always be validated on the server side.

43  2008 Pearson Education, Inc. All rights reserved. 43 Error-Prevention Tip 23.3 Be sure to close any open XHTML tags when calling function die. Not doing so can produce invalid XHTML output that will not display properly in the client browser. Function die has an optional parameter that specifies a message to output when exiting, so one technique for closing tags is to close all open tags using die, as in die(" ").

44  2008 Pearson Education, Inc. All rights reserved. 44 Outline data.html (1 of 2)

45  2008 Pearson Education, Inc. All rights reserved. 45 Outline data.html (2 of 2)

46  2008 Pearson Education, Inc. All rights reserved. 46 Outline database.php (1 of 3)

47  2008 Pearson Education, Inc. All rights reserved. 47 Outline database.php (2 of 3)

48  2008 Pearson Education, Inc. All rights reserved. 48 Outline database.php (3 of 3)

49  2008 Pearson Education, Inc. All rights reserved. 49 Outline cookies.html (1 of 2)

50  2008 Pearson Education, Inc. All rights reserved. 50 Outline cookies.html (2 of 2)

51  2008 Pearson Education, Inc. All rights reserved. 51 Outline cookies.php (1 of 2)

52  2008 Pearson Education, Inc. All rights reserved. 52 Outline cookies.php (2 of 2)

53  2008 Pearson Education, Inc. All rights reserved. 53 Software Engineering Observation 23.2 Some clients do not accept cookies. When a client declines a cookie, the browser application normally informs the user that the site may not function correctly without cookies enabled.

54  2008 Pearson Education, Inc. All rights reserved. 54 Software Engineering Observation 23.3 Cookies should not be used to store e-mail addresses or private data on a client’s computer.

55  2008 Pearson Education, Inc. All rights reserved. 55 Fig. 23.18 | IE7’s Cookies directory before a cookie is written.

56  2008 Pearson Education, Inc. All rights reserved. 56 Fig. 23.19 | IE7’s Cookies directory after a cookie is written.

57  2008 Pearson Education, Inc. All rights reserved. 57 Outline readCookies.php (1 of 2)

58  2008 Pearson Education, Inc. All rights reserved. 58 Outline readCookies.php (2 of 2)

59  2008 Pearson Education, Inc. All rights reserved. 59 Outline dynamicForm.php (1 of 12)

60  2008 Pearson Education, Inc. All rights reserved. 60 Outline dynamicForm.php (2 of 12)

61  2008 Pearson Education, Inc. All rights reserved. 61 Outline dynamicForm.php (3 of 12)

62  2008 Pearson Education, Inc. All rights reserved. 62 Outline dynamicForm.php (4 of 12)

63  2008 Pearson Education, Inc. All rights reserved. 63 Outline dynamicForm.php (5 of 12)

64  2008 Pearson Education, Inc. All rights reserved. 64 Outline dynamicForm.php (6 of 12)

65  2008 Pearson Education, Inc. All rights reserved. 65 Outline dynamicForm.php (7 of 12)

66  2008 Pearson Education, Inc. All rights reserved. 66 Outline dynamicForm.php (8 of 12)

67  2008 Pearson Education, Inc. All rights reserved. 67 Outline dynamicForm.php (9 of 12)

68  2008 Pearson Education, Inc. All rights reserved. 68 Outline dynamicForm.php (10 of 12)

69  2008 Pearson Education, Inc. All rights reserved. 69 Outline dynamicForm.php (11 of 12)

70  2008 Pearson Education, Inc. All rights reserved. 70 Outline dynamicForm.php (12 of 12)

71  2008 Pearson Education, Inc. All rights reserved. 71 Outline formDatabase.php (1 of 3)

72  2008 Pearson Education, Inc. All rights reserved. 72 Outline formDatabase.php (2 of 3)

73  2008 Pearson Education, Inc. All rights reserved. 73 Outline formDatabase.php (3 of 3)

74  2008 Pearson Education, Inc. All rights reserved. 74 Fig. 23.23 | PHP operator precedence and associativity. (Part 1 of 3.)

75  2008 Pearson Education, Inc. All rights reserved. 75 Fig. 23.23 | PHP operator precedence and associativity. (Part 2 of 3.)

76  2008 Pearson Education, Inc. All rights reserved. 76 Fig. 23.23 | PHP operator precedence and associativity. (Part 3 of 3.)


Download ppt " 2008 Pearson Education, Inc. All rights reserved. 1 23 PHP."

Similar presentations


Ads by Google