PHP Developer''''s Dictionary- P22 pot

5 224 0
PHP Developer''''s Dictionary- P22 pot

Đang tải... (xem toàn văn)

Thông tin tài liệu

PHP Developer’s Dictionary IT-SC book 105 string SERVER_PROTOCOL Description The SERVER_PROTOCOL variable contains the name and version of the protocol used in the request. For example, HTTP/1.1 is a valid value for SERVER_PROTOCOL. SERVER_SIGNATURE Syntax string SERVER_SIGNATURE Description The SERVER_SIGNATURE variable contains the server host name and version number. SERVER_SOFTWARE Syntax string SERVER_SOFTWARE Description The SERVER_SOFTWARE variable contains the server string, which is similar to a user- agent (or browser) string. PHP The last section of this chapter contains PHP variables that are constant within the PHP installation. Additionally, there are a couple of variables that are present when PHP scripts are run on the command line. argv Syntax array argv PHP Developer’s Dictionary IT-SC book 106 Description The argv array contains a list of options passed to the PHP script if it was executed on the command line. argc Syntax int argc Description The argc variable contains the number of options that were passed to the PHP script if it was executed on the command line. PHP_SELF Syntax string PHP_SELF Description The PHP_SELF variable contains the filename of the script currently being processed, relative to the document root. Please note that this variable is not available if you are running the PHP interpreter on the command line. HTTP_COOKIE_VARS Syntax array HTTP_COOKIE_VARS Description HTTP_COOKIE_VARS contains an associative array of keys and values passed to the PHP script via cookies, which are available in the HTTP header. This is available only if the tracking variables have been turned on within the PHP environment. This can be accomplished in either of the following ways: PHP Developer’s Dictionary IT-SC book 107 • <?php_track_vars?> (no longer supported in PHP 4) • track_vars configuration file directive HTTP_GET_VARS Syntax array HTTP_GET_VARS Description HTTP_GET_VARS contains an associative array of keys and values passed to the PHP script via the HTTP GET method of form submission. This is available only if the tracking variables have been turned on within the PHP environment. This can be accomplished in either of the following ways: • <?php_track_vars?> (no longer supported in PHP 4) • track_vars configuration file directive HTTP_POST_VARS Syntax array HTTP_POST_VARS Description HTTP_POST_VARS contains an associative array of keys and values passed to the PHP script via the HTTP POST method of form submission. This is available only if the tracking variables have been turned on within the PHP environment. This can be accomplished in either of the following ways: • <?php_track_vars?> (no longer supported in PHP 4) • track_vars configuration file directive PHP Developer’s Dictionary IT-SC book 108 Chapter 5. PHP Language Extensions This chapter primarily details which functions are available in PHP to work with numbers, arrays, and strings. In addition, this chapter describes functions that provide information about the environment and variables that are available to the PHPs cript that is currently running. Arbitrary-Precision Mathematics PHP's arbitrary-precision mathematics functions enable you to perform mathematical operations on real numbers, which include integers, longs, floats, and doubles. The term arbitrary-precision stems from the ability you have with these functions to specify a scale parameter. Scale represents the number of digits to the right of the decimal point in a number that should be considered in both the calculation and the output. In PHP, arbitrary-precision numbers are represented as strings for parameters and return values. These functions are part of the bcmath library, which must be separately compiled into PHP (using enable-bcmath during configuration) because of licensing restrictions. For more information, consult the readme.bcmath file that is included with the PHP source files. bcadd() Syntax string bcadd(string left_operand, string right_operand, [int scale]) Description The bcadd() function calculates the sum of the left and right operands and returns the result as a string. The optional scale parameter is used to indicate the number of digits to the right of the decimal point in the result. If scale is omitted, it defaults to 0 . echo bcadd(2.002,2.002,2);//result is 4.00 echo bcadd(2.009,2.009,2);//result is 4.00 bccomp() Syntax int bccomp(string left_operand, string right_operand, [int scale]) PHP Developer’s Dictionary IT-SC book 109 Description The bccomp() function performs a numeric comparison on the left and right operands. The result is +1 when the left_operand is greater than the right_operand and –1 when the left_operand is less than the right_operand . If both are equal, the result is 0. The optional scale parameter is used to indicate the number of digits to the right of the decimal point that should be considered in the comparison. If scale is omitted, it defaults to 0 . echo bccomp(2.005,2.009,2);//result is 0 echo bccomp(2.00,3.00,2);//result is -1 echo bccomp(3.00,2.00,2);//result is 1 bcdiv() Syntax string bcdiv(string left_operand, string right_operand, [int scale]) Description The bcdiv() function calculates the quotient of the left_operand divided by the right_operand . The optional scale parameter indicates the number of digits to the right of the decimal point in the result. If scale is omitted, it defaults to 0 . If the right_operand is 0 , a divide-by-zero warning will occur. echo bcdiv(2.005,1.009,2);//result is 2 echo bcdiv(10.00,3.00,2);//result is 3.33 echo bcdiv(2.00,3.00,2);//result is 0.66 echo bcdiv(2.00,0.005,2);//result is a divide by zero warning bcmod() Syntax string bcmod(string left_operand , string modulus ) Description The bcmod() function divides the left_operand by the modulus and returns the remainder. . string. PHP The last section of this chapter contains PHP variables that are constant within the PHP installation. Additionally, there are a couple of variables that are present when PHP scripts. number of options that were passed to the PHP script if it was executed on the command line. PHP_ SELF Syntax string PHP_ SELF Description The PHP_ SELF variable contains the filename. within the PHP environment. This can be accomplished in either of the following ways: PHP Developer’s Dictionary IT-SC book 107 • < ?php_ track_vars?> (no longer supported in PHP 4) •

Ngày đăng: 07/07/2014, 05:20

Mục lục

  • PHP Developer's Dictionary

  • Acknowledgments

    • Tell Us What You Think!

    • Introduction

      • Who Should Buy This Book?

      • Organization of the Chapters

      • Chapter 1. Basic PHP Background and History

        • Advantages of PHP 4

        • Installation

          • PHP Installation General Overview

          • Types, Variables, and Constants

          • Operators and Mathematical Functions

            • Expressions and Operators

            • Functions, Classes, and Objects

              • Functions

              • Chapter 2. Generating HTML

                • Generating Dynamic Content

                  • Defining Dynamic Content

                  • Using Request Variables to Generate Content

                  • Using the Environment to Generate Content

                  • Working with the Filesystem

                    • Directory Functions

                    • Working with Email

                      • Email Overview

                      • Calendar and Date Functions

                        • Overview of Time and Date Functions

                        • Chapter 3. Database Access

                          • Working with Connections and Data Sources

                            • Setting Up the Database

                            • Using PostgreSQL and PHP

                              • PostgreSQL Overview

                              • Connecting Postgres and PHP

                              • Select, Insert, Update, and Delete Queries

                                • Insert Queries

                                • Select Queries with PHP

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan