Danh mục tài liệu

Professional PHP Programming phần 2

Số trang: 86      Loại file: pdf      Dung lượng: 2.33 MB      Lượt xem: 17      Lượt tải: 0    
Xem trước 9 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

Một đoạn văn với một khởi đầu như thế này trong kịch bản Latin sẽ có một mức độ mặc định nhúng Level 0, và do đó hướng cơ bản của nó sẽ được trái sang phải.Các thuật toán bidi sử dụng tất cả các mã định dạng và mức độ nhúng để phân tích văn bản để quyết định làm thế nào nó phải được trả lại. Dưới đây là một thời gian ngắn
Nội dung trích xuất từ tài liệu:
Professional PHP Programming phần 2Simpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com T o create this JavaScript code dynamically through PHP, we must be careful to escape the backslashes in PHP so that they are passed literally to the JavaScript. For example, consider what happens if we leave the backslashes unescaped: T his is what we would see if we View Source in the browser: T he newlines and tabs were interpreted by PHP instead of being passed as literal characters to JavaScript. This was not our intended effect. We want JavaScript to interpret these symbols as newlines and tabs, not PHP. The code below corrects this problem: TEAM FLY PRESENTSSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com B asically, we escape the \ n by typing \ \n . PHP will not interpret it as a newline, but rather as the literal characters \ a nd n . These will be passed on to the browser, where JavaScript will then interpret them as a newline. Similarly, the PHP code \ \t c auses \ t t o be passed to the browser, which is correctly interpreted as a tab by JavaScript. Summary I n the chapter, we learned how PHP interacts with the browser, how it receives HTML form data, and how it dynamically generates HTML documents. Upon submission, HTML form data are converted to name/value pairs and sent to the web server in a URL-encoded query string. URL encoding ensures that reserved characters are safely masked and that name/value pairs are represented in a standard way. PHP receives the data in the form of variables. URL encoding can also be used to pass variables from one PHP script to another. PHP provides three notations for comments: ❑ // Comment ❑ # Comment /* ❑ Comment */ T he first two of the comment types are used to comment single lines. The third type of comment code can be used to comment blocks of multiple lines. The backslash (\ ) is used to e scape a c haracter. Characters are often escaped to indicate a literal depiction of the character: e cho (The variable \$applicant equals $applicant.); S ome escape sequences have special meanings, such as \ n (newline) and \t ( tab). TEAM FLY PRESENTSSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 4 1 Variables, Constants , and Data Types I n the previous chapter, we met PHP variables and saw briefly how to use them. We stated that PHP variables must begin with the dollar character ( $ ) and that PHP is a weakly-typed language – that is, variables can contain any type of data and do not have to be predefined as strings, integers, etc. We also saw how we can use PHP variables to extract data from an HTML form. In this chapter, we will look in more detail at variables and their data types. We will consider the issue of data type juggling in more detail, and we will look at some of the functions we can use to manipulate variables. We will also see how to assign a name to a constant value, which remains the same throughout the program. Data Types P HP has three basic data types: integer, double and string. There are also some not-so-basic types, namely arrays and objects, which are discussed in later chapters. Every variable has a specific type, though, as we’ve already mentioned, a variable’s type may change on the fly as the variable’s value changes, or as the code otherwise dictates. Integers use four bytes of memory and are used to represent ordinary, non-decimal numbers in the range of approximately –2 billion to +2 billion. Doubles, also known as float (floating-point) or real numbers, are used to represent numbers that contain a decimal value or an exponent. Strings are used to represent non- numeric values, like letters, punctuation marks, and even numerals. 2 // This is an integer 1 [JHS] Ive added a bit of an introduction to avoid the abrupt start to the chapter. The chapter seems technically accurate, but I think we could do with a bit more explantion in places. The major topic which is omitted from this chapter is HTTP environment variables. We need a large section on these. While a complete listing should form an appendix, we need to show in this chapter how to access HTTP variables from PHP and to give a couple of practical examples: it would be good if these could be incorporated into the Job Application Form. TEAM FLY PRESENTSSimpo PDF Merge and Split Unregistered Version - http://www.simpopdf.com 2.0 // This is a double 2 // This is a string 2 hours // This is another string M any languages contain a Boolean data type to represent the logical values T RUE a nd F ALSE . PHP does not. It instead uses expressions of the other three basic types tha ...

Tài liệu được xem nhiều:

Tài liệu có liên quan: