1 / 37

ACM 511

ACM 511. IntroductION to SERVER-SIDE WEB PROGRAMMING. Web Development Environment.

efrat
Download Presentation

ACM 511

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ACM 511 IntroductION to SERVER-SIDE WEB PROGRAMMING ACM 262 Course Notes

  2. Web Development Environment Authoring Web pages is not a particularly difficult task now-a-days. Many standard desktop software packages come equipped with built-in features to convert word processing documents, spreadsheets, databases, and the like to coded documents that are ready for access across the Web. Special Web page authoring packages such as Microsoft FrontPageand AdobeDreamweaver permit creation of Web pages with drag-and-drop ease. In most of these cases it is not even necessary to know or to be aware of the special HTML(HyperText Markup Language) coding that takes place behind the scenes. If you know the XHTML language, then you can author your Web pages with a simple text editor, usually gaining a great deal more control over their structure and formatting than is possible with drag-and-drop methods. In addition, you have the ability to easily integrate existing XHTML code, Java applets, multimedia plug-ins, and browser scripting languages to bring a modicum of user interactively to your pages. ACM 365 Course Notes

  3. Web Development Environment Web "development," as contrasted with Web page "authoring," goes well beyond the use of markup codes and a few plug-ins or scripting techniques to make attractive and informative Web pages. The term pertains to the use of special strategies, tools, and methods for producing Web pages and Web sites characterized as three-tier, client/server, and information processing systems. Web technologies are used to produce not just simple personal or promotional Web sites containing informative, interesting, or entertaining material for public consumption. Rather, they are becoming important means for supporting the foundational "business processes" of modern organizations -- the underlying operational and management-support functions. The technical infrastructures for supporting these purposes are roughly classified into three types of Web-based systems, termed: intranets, internets, and extranets. ACM 365 Course Notes

  4. Web Development Environment ACM 365 Course Notes

  5. Information Processing Model The input function permits users to interact with the system, requesting processing options, controlling information access, and specifying delivery methods. Plus, the user can become the source of the data which the system processes and which it maintains in its repositories of stored information. The processing function refers to the data manipulation activities and the processing logic needed to carry out the work of the system. The term implies that the system can be "programmed" to perform the arithmetic and logical operations necessary to manipulate input data and to produce output information. The output function delivers the results of processing to the user in a correct, timely, and appropriately formatted fashion. The storage function ensures the currency and integrity of processed information, maintaining it over the long term and permitting it to be added to, changed, or deleted in systematic fashion. In the final analysis, stored information becomes the primary content of Web pages. ACM 365 Course Notes

  6. PHP http://www.sedh.gr/tutorials/web_dev/PHP/default.htm http://phptester.net/ ACM 365 Course Notes

  7. PHP XML tag style <?phpPHP Code Block?> Short style <?PHP Code Block?> Tag style <script language="php">PHP Code Block</script> ACM 365 Course Notes

  8. Mixing HTML and PHP ACM 365 Course Notes

  9. Displaying Content The echo and print statements appear in the following format: echo - used to output one or more strings. echo "Text to be displayed"print - used to output a string. In some cases the print statement offers greater functionality than the echo statement. These will be discussed in later tutorials. For now print can be considered an alias for echo. print "Text to be displayed“ With both the echo and print statements, it is necessary to use a <p> or <br/> tag to create paragraphs or line breaks. ACM 365 Course Notes

  10. Displaying Content ACM 365 Course Notes

  11. Instruction Terminator ACM 365 Course Notes

  12. Commenting your code // - simple PHP comment # - alternative simple PHP comment /*...*/ - multi-line comment blocks. Comments are ignored by the PHP parser. ACM 365 Course Notes

  13. Commenting your code ACM 365 Course Notes

  14. Scalar Variables Variables are temporary place holders used to represent values used in a PHP script. PHP includes two main types of variables: scalar and array. Scalar variables contain only one value at a time , and array variables contain a list of values. PHP scalar variables contain the following types: Integers - whole numbers or numbers without decimals. (1, 999, 325812841) Floating-point numbers (also known as floats or doubles) - Numbers that contain decimals. (1.11, 2.5, .44) Strings - text or numeric information. String data is always specified with quotes ("Hello World", "478-477-5555") Boolean - used for true or false values PHP variables of all types begin with the "$" sign. Variable names can contain letters, numbers, and the (_) underscore character. Variables cannot, however, begin with numbers. In PHP variable names are case sensitive. ACM 365 Course Notes

  15. Scalar Variables Legal Variable Names $myvar$F_Name$address1 $my_string_variable Illegal Variable Names Myvar$&62##  $username = "jdoe"$first_name = "John"$Last_Name = "Doe" ACM 365 Course Notes

  16. Scalar Variables ACM 365 Course Notes

  17. Scalar Variables ACM 365 Course Notes

  18. Scalar Variables Variable Concatenation The dot operator can also be used to join strings and variables ACM 365 Course Notes

  19. Scalar Variables • Interpolation • PHP also supports a process known as interpolation - replacing a variable with its contents within a string. ACM 365 Course Notes

  20. Array Variables While a PHP scalar variable stores a single value, an array variable can be used to store a set or sequence of values. PHP supports numerically indexed arrays and associative arrays. An array in PHP is actually an ordered map. A map is a type that maps values to keys. Array variables consist of two parts - an index and an element. The array index, sometimes referred to as the array key, is a value used to identify or access array elements. The array index is placed in square brackets. Most arrays use numeric indices that typically start with 0 or 1. In PHP associative arrays can use string indices. Both types of arrays are created using the array() construct. ACM 365 Course Notes

  21. Array Variables Numerically Indexed Arrays $my_array = array('red', 'green', 'blue') This code creates a numerically indexed array called $my_array. The array is assigned three elements - red, green, and blue. Each element is identified by a numeric index. $my_array[0] = 'red' //index 0 corresponds to element red $my_array[1] = 'green' // index 1 corresponds to element green $my_array[2] = 'blue' // index 2 corresponds to element blue ACM 365 Course Notes

  22. Array Variables ACM 365 Course Notes

  23. Array Variables Associative Arrays Associative arrays allow you to use more useful index values. With numerically indexed arrays, index values are created automatically beginning with 0. Associative arrays permit numeric and string index values. The symbol between the index and values (=>) is an equal sign immediately followed by a greater than symbol. $members = array('FName' => John, 'LName' => Smith, 'Age' => 50) In this example, the array members contain three elements, however the string indices - FName, LName, and Age are used. $members['FName'] = 'John' //index FName corresponds to element John $members['LName'] = 'Smith' // index LName corresponds to element Smith $members['Age'] = '50' // index Age corresponds to element 50 ACM 365 Course Notes

  24. Array Variables ACM 365 Course Notes

  25. Array Variables Array Functions count() - the count function is used to count the number of elements in an array. sort() - the sort function is used to sort the elements of an existing array.shuffle() - the shuffle function is used to randomize the elements of a given array.sizeof() - the sizeof function is an alias of the count() function.array_slice($array_name,offset, length) - the array_slice function is used to extract a chuck of an existing array.$array_name is the name of the array to slice, offset denotes the position where the slice will begin, length indicates the number of elements that will be sliced from the array.array_merge($array_name, $array_name) - the array_merge function is used to combine or merge two or more existing arrays. The names of the arrays are separated by commas. ACM 365 Course Notes

  26. Array Variables ACM 365 Course Notes

  27. Constants A constant, like a variable, is a temporary placeholder in memory that holds a value. Unlike variables, the value of a constant never changes. When a constant is declared, the define() function is used and requires the name of the constant and the value you want to give the constant. Constants can be assigned the following types of data: Integers - whole numbers or numbers without decimals. (1, 999, 325812841) Floating-point numbers (also known as floats or doubles) - Numbers that contain decimals. (1.11, 2.5, .44) Strings - text or numeric information. String data is always specified with quotes ("Hello World", "478-477-5555") ACM 365 Course Notes

  28. Constants PHP constants unlike variables do not begin with the "$" sign. Constant names are usually uppercase. Constant names can contain letters, numbers, and the (_) underscore character. Constants cannot, however, begin with numbers. Declaring constants is demonstrated below: define("STRING_CONSTANT", "This is my string.");  define("NUMERIC_CONSTANT", 5); ACM 365 Course Notes

  29. Constants ACM 365 Course Notes

  30. Operators 3 examples ACM 365 Course Notes

  31. Operators ACM 365 Course Notes

  32. Operators ACM 365 Course Notes

  33. Operators ACM 365 Course Notes

  34. Strings Single Quoted StringsSingle quotes provide the easiest method for working with strings. Using this method, strings are surrounded by single quotes (''). If single quotes are needed as part of the display, they must be escaped with the backslash ("\") character. While single quotes provide an easy method for working with strings, single quotes do not support the use of interpolation. Double Quoted Strings PHP strings can also be displayed using double quotes (""). If PHP strings are enclosed in double quotes, it is possible to take advantage of interpolation. With double quoted strings, PHP also supports more escape characters ACM 365 Course Notes

  35. Strings ACM 365 Course Notes

  36. Strings strlen(string) - determines the length of a string. ltrim(string) - strips whitespace from the beginning of a string.rtrim(string) - strips whitespace from the end of a string.strpbrk(string, char) - Searchs the string for the character (char). Returns false or string beginning with the character found.strtoupper(string) - converts string to uppercase.strtolower(string) - converts string to lowercase.strrev(string) - reverses a string.eregi(string pattern, string subject) - Performs a case insensitive expression match. Searches subject for a match to the regular expression given in pattern. ACM 365 Course Notes

  37. Strings ACM 365 Course Notes

More Related