Php ini_get function tutorial

Source: Internet
Author: User

Php ini_get function tutorial

Get_ini
(PHP 4 and PHP 5)

How to get-a configuration option for getting value

Description
How to obtain a string (string $ varname)
The configuration option of the returned value is successful.

Parameters

Varname
The name of the configuration option.


Return Value
The configuration option of the returned value is a string success, a NULL string failure, or a NULL value.

Instance

Example #1: How to obtain ()

<? Php
/*
Our php. ini contains the following settings:

Display_errors = On
Register_globals = Off
Post_max_size = 8 M
*/

Echo 'display _ errors = '. ini_get ('display _ errors'). "n ";
Echo 'register _ globals = '. ini_get ('register _ globals'). "n ";
Echo 'Post _ max_size = '. ini_get ('Post _ max_size'). "n ";
Echo 'Post _ max_size + 1 = '. (ini_get ('Post _ max_size') + 1). "n ";
Echo 'Post _ max_size in bytes = '. return_bytes (ini_get ('Post _ max_size '));

Function return_bytes ($ val ){
$ Val = trim ($ val );
$ Last = strtolower ($ val [strlen ($ val)-1]);
Switch ($ last ){
// The 'G' modifier is available since PHP 5.1.0
Case 'G ':
$ Val * = 1024;
Case 'M ':
$ Val * = 1024;
Case 'K ':
$ Val * = 1024;
}

Return $ val;
}

?>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.