5555Our php.ini contains the following settings:
5656
5757display_errors = On
58- register_globals = Off
58+ opcache.enable_cli = Off
5959post_max_size = 8M
6060*/
6161
6262echo 'display_errors = ' . ini_get('display_errors') . "\n";
63- echo 'register_globals = ' . (int) ini_get('register_globals ') . "\n";
63+ echo 'opcache.enable_cli = ' . (int) ini_get('opcache.enable_cli ') . "\n";
6464echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
6565echo 'post_max_size + 1 = ' . (rtrim(ini_get('post_max_size'), 'KMG') + 1) . "\n";
66- echo 'post_max_size in bytes = ' . return_bytes(ini_get('post_max_size'));
67-
68- function return_bytes($val)
69- {
70- $val = trim($val);
71- $num = (int) rtrim($val, 'KMG');
72- $last = strtolower($val[strlen($val) - 1]);
73-
74- switch ($last) {
75- // The 'G' modifier is available
76- case 'g':
77- $num = $num * 1024 * 1024 * 1024;
78- break;
79- case 'm':
80- $num = $num * 1024 * 1024;
81- break;
82- case 'k':
83- $num *= 1024;
84- break;
85- }
86-
87- return $num;
88- }
66+ echo 'post_max_size in bytes = ' . ini_parse_quantity(ini_get('post_max_size'));
8967
9068?>
9169]]>
@@ -95,7 +73,7 @@ function return_bytes($val)
9573<![CDATA[
9674
9775display_errors = 1
98- register_globals = 0
76+ opcache.enable_cli = 0
9977post_max_size = 8M
10078post_max_size+1 = 9
10179post_max_size in bytes = 8388608
@@ -126,9 +104,9 @@ post_max_size in bytes = 8388608
126104 <function >ini_get</function > will return the exact string stored in the
127105 &php.ini; file and <emphasis >NOT</emphasis > its <type >int</type >
128106 equivalent. Attempting normal arithmetic functions on these values
129- will not have otherwise expected results. The example above shows one
130- way to convert shorthand notation into bytes, much like how the PHP
131- source does it .
107+ will not have otherwise expected results. The
108+ < function >ini_parse_quantity</ function > function can be used to convert
109+ the shorthand notation into bytes .
132110 </para >
133111 </note >
134112 <note >
@@ -145,6 +123,7 @@ post_max_size in bytes = 8388608
145123 <simplelist >
146124 <member ><function >get_cfg_var</function ></member >
147125 <member ><function >ini_get_all</function ></member >
126+ <member ><function >ini_parse_quantity</function ></member >
148127 <member ><function >ini_restore</function ></member >
149128 <member ><function >ini_set</function ></member >
150129 </simplelist >
0 commit comments