Home Backend Development PHP Tutorial Dont stop til you get enough PHP options and related information function library

Dont stop til you get enough PHP options and related information function library

Jul 29, 2016 am 08:35 AM

error_log: Send an error message.
error_reporting: Configure the level of error information reporting.
getenv: Get the system environment variables
get_cfg_var: Get the configuration option value of PHP.
get_current_user: Get the owner name of the PHP trip.
get_magic_quotes_gpc: Get the value of PHP environment variable magic_quotes_gpc.
get_magic_quotes_runtime: Get the value of PHP environment variable magic_quotes_runtime.
getlastmod: Returns the last modification time of the web page.
getmyinode: Returns the inode value of the web page.
getmypid: Returns the trip code of PHP.
getmyuid: Returns the user code of PHP.
getrusage: Returns the system resource usage.
phpinfo : Returns all relevant information about PHP.
phpversion : Returns PHP version information.
putenv: Configure system environment variables.
set_magic_quotes_runtime : Configure magic_quotes_runtime value.
set_time_limit: Configure the longest execution time of this page.
int error_log
Syntax: int error_log(string message, int message_type, string [destination], string [extra_headers]);
Return value: integer
Function type: PHP system function
Content description: This function will send error information to the Web Server error log file, TCP Port, or to the specified file. The first parameter message is the error message to be sent. The second parameter message_type is an integer value: 0 means sending the log to the operating system (UNIX records events in syslog and Windows NT); 1 uses PHP's Mail() function to send the information to an E-Mail. The four parameters extra_headers will also be used; 2 will send the error message to the TCP port, and the third parameter destination represents the destination IP and Port; 3 will save the information in the file destination.
Usage Example
This example is to handle the problem of logging into the Oracle database.
if (!Ora_Logon($username, $password)) {
error_log("Oracle database is unavailable!", 0);
}
if (!($foo = allocate_new_foo()) {
error_log ("Big trouble!", 1, "webmaster@www.mydomain.com.tw");
}
error_log("Screwed up!", 2, "127.0.0.1:7000");
error_log( "Screwed up!", 2, "loghost");
error_log("Screwed up!", 3, "/var/tmp/my-errors.log");
?>
error_reporting
Configuration error information The level of reporting.
Syntax: int error_reporting(int [level]);
Return value: integer
Function type: PHP system function
Content description: This function is used to configure the level of error message reporting. The parameter level is an integer bit. Mask (bitmask), see the table below
Mask value represents the name
1 E_ERROR
2 E_WARNING
4 E_PARSE
8 E_NOTICE
16 E_CORE_ERROR
32 E_CORE_WARNING
E_NOTICE represents the general situation of not recording , only used when there is an error in the program , such as trying to access a variable that does not exist, or calling the stat() function to view a file that does not exist.
E_WARNING will usually be displayed, but it will not interrupt the execution of the program. For example, it is very effective for debugging. The regular expression in question is called ereg().
E_ERROR will usually be displayed and will interrupt program execution. This means that memory configuration or other errors cannot be traced from the syntax
E_CORE_ERROR. E_ERROR, but does not include errors caused by PHP core.
E_CORE_WARNING Similar to E_WARNING, but does not include PHP core error warnings
getenv
Get the system environment variables
Syntax: string getenv(string varname);
Return value: String
Function type : PHP system function
Content description: If the environment variable varname is obtained correctly, the variable value will be returned. If it fails, false will be returned.
Usage example
The following example can obtain the URL of the machine where the user's browser is located
$ip = getenv( "REMOTE_ADDR");
?>
get_cfg_var
Get the configuration option value of PHP.
Syntax: string get_cfg_var(string varname);
Return value: String
Function type: PHP system function
Content description: If the current PHP configuration option varname is correctly obtained, the variable value is returned. Returns false on failure.
get_current_user
Get the owner name of PHP trip.
Syntax: string get_current_user(void);
Return value: String
Function type: PHP system function
Content description: This function is used to obtain the owner name of the PHP program process.
Reference: getmyuid() getmypid() getmyinode() getlastmod()
get_magic_quotes_gpc
Get the value of PHP environment variable magic_quotes_gpc.
Syntax: long get_magic_quotes_gpc(void);
Return value: Long integer
Function type: PHP system function
Content description: This function obtains the value of the PHP environment configuration variable magic_quotes_gpc (GPC, Get/Post/Cookie). Returning 0 means turning off this function; returning 1 means turning this function on. When magic_quotes_gpc is turned on, all ' (single quote), " (double quote), (backslash) and null characters will be automatically converted to overflow characters containing backslashes.
Reference: get_magic_quotes_runtime() set_magic_quotes_runtime()
get_magic_quotes_runtime
Get the value of the PHP environment variable magic_quotes_runtime.
Syntax: long get_magic_quotes_runtime(void);
Return value: Long integer
Function type: PHP system function
Content description: This function gets the value of the PHP environment configuration variable magic_quotes_runtime. Returning 0 means closed. This function; returns 1 to indicate that this function is turned on. If magic_quotes_runtime is turned on, all externally imported database data or files will be automatically converted to data containing backslash overflow characters.
Reference: get_magic_quotes_gpc() set_magic_quotes_runtime()
getlastmod
Returns the last modification time of the web page.
Syntax: int getlastmod(void);
Return value: Integer
Function type: PHP system function
Content description: This function returns the last modification time of the web page specified by this function, and the returned value is UNIX Timestamp (timestamp) format, you can use the 4.7.2 date() function to format the return value. If the execution fails, it will return a false value.
Usage example: The following example returns a value similar to 'This page was last modified: June 19 1999 20 :43:59.'
echo "This page was last modified: ".date("F d Y H:i:s.", getlastmod());
?>
Reference: date( ) getmyuid() get_current_user() getmyinode() getmypid()
getmyinode
Returns the inode value of the webpage.
Syntax: int getmyinode(void);
Return value: Integer
Function type: PHP system function
Content description: This function Return the inode value of the web page. If the execution fails, return the false value.
Reference: getmyuid() get_current_user() getmypid() getlastmod()
getmypid
Return the PHP trip code.
Syntax: int getmypid(void);
Return value: Integer
Function type: PHP system function
Content description: This function returns the PHP trip code value (PID). If the execution fails, a false value is returned. When PHP exists as an Apache module, the returned PID value may not be correct.
Reference: getmyuid() get_current_user() getmyinode() getlastmod()
getmyuid
Return the user code of PHP.
Syntax: int getmyuid(void);
Return value: Integer
Function type: PHP system function
Content description: This function returns the PHP user code (UID). If the execution fails, a false value is returned.
Reference: getmypid() get_current_user() getmyinode() getlastmod()
getrusage
Returns the system resource usage.
Syntax: array getrusage(int [who]);
Return value: array
Function type: PHP system function
Content description: This function uses the UNIX system call getrusage(2). The returned information is returned in the form of an array. If the parameter who is 1, this function will call RUSAGE_CHILDREN. Further information can be found in the UNIX library documentation.
Usage example
$dat = getrusage();
echo $dat["ru_nswap"]; // Number of Swaps
echo $dat["ru_majflt"]; // Number of pages
echo $dat[ "ru_utime.tv_sec"]; // Usage time (seconds)
echo $dat["ru_utime.tv_usec"]; // Usage time (milliseconds)
?>
phpinfo
Returns all relevant information of PHP.
Syntax: int phpinfo(void);
Return value: Integer
Function type: PHP system function
Content description: This function returns all information of PHP. Includes PHP compilation options and extended configurations, PHP version, server information and environment variables, PHP environment variables, operating system version information, path and environment variable configuration, HTTP headers, and copyright notices.
Reference: phpversion()
phpversion
Return PHP version information.
Syntax: string phpversion(void);
Return value: String
Function type: PHP system function
Content description: This function returns PHP version information.
Usage example
The return value in the following example is similar to 'This site uses PHP version: 3.0.11'
echo "This site uses PHP version: ".phpversion();
?>
Reference: phpinfo ()
putenv
Configure system environment variables.
Syntax: void putenv(string setting);
Return value: None
Function type: PHP system function
Content description: This function is used to configure system environment variables.
Usage Example
Configure the environment variable NLS_LANG required for Oracle database, and the returned data contains Chinese BIG5 code. putenv("NLS_LANG=american_taiwan.zht16big5");
?>
set_magic_quotes_runtime
Configure magic_quotes_runtime value.
Syntax: long set_magic_quotes_runtime(int new_setting);
Return value: Long integer
Function type: PHP system function
Content description
This function is used to configure the magic_quotes_runtime value.
Reference: get_magic_quotes_gpc() get_magic_quotes_runtime()
set_time_limit
Configure the longest execution time of this page.
Syntax: void set_time_limit(int seconds);
Return value: None
Function type: PHP system function
Content description: This function is used to configure the longest execution time of the page. The default value is 30 seconds, which is configured in the max_execution_time variable in php.ini. If it is configured as 0, the maximum time is not limited. The calculation starts when this function is executed. For example, if the default is 30 seconds, and 25 seconds have been executed before this function is executed, and this function is used to change it to 20 seconds, the maximum execution time of the page will be 45 seconds.

The above has introduced the Dont stop til you get enough PHP option and related information function library, including the content of Dont stop til you get enough. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1665
14
PHP Tutorial
1270
29
C# Tutorial
1250
24
Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Explain secure password hashing in PHP (e.g., password_hash, password_verify). Why not use MD5 or SHA1? Apr 17, 2025 am 12:06 AM

In PHP, password_hash and password_verify functions should be used to implement secure password hashing, and MD5 or SHA1 should not be used. 1) password_hash generates a hash containing salt values ​​to enhance security. 2) Password_verify verify password and ensure security by comparing hash values. 3) MD5 and SHA1 are vulnerable and lack salt values, and are not suitable for modern password security.

PHP and Python: Comparing Two Popular Programming Languages PHP and Python: Comparing Two Popular Programming Languages Apr 14, 2025 am 12:13 AM

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP in Action: Real-World Examples and Applications PHP in Action: Real-World Examples and Applications Apr 14, 2025 am 12:19 AM

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP: A Key Language for Web Development PHP: A Key Language for Web Development Apr 13, 2025 am 12:08 AM

PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

The Enduring Relevance of PHP: Is It Still Alive? The Enduring Relevance of PHP: Is It Still Alive? Apr 14, 2025 am 12:12 AM

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

How does PHP type hinting work, including scalar types, return types, union types, and nullable types? How does PHP type hinting work, including scalar types, return types, union types, and nullable types? Apr 17, 2025 am 12:25 AM

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values ​​and handle functions that may return null values.

PHP and Python: Code Examples and Comparison PHP and Python: Code Examples and Comparison Apr 15, 2025 am 12:07 AM

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.

PHP vs. Other Languages: A Comparison PHP vs. Other Languages: A Comparison Apr 13, 2025 am 12:19 AM

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

See all articles