55
55
Our php.ini contains the following settings:
56
56
57
57
display_errors = On
58
- register_globals = Off
58
+ opcache.enable_cli = Off
59
59
post_max_size = 8M
60
60
*/
61
61
62
62
echo '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";
64
64
echo 'post_max_size = ' . ini_get('post_max_size') . "\n";
65
65
echo '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'));
89
67
90
68
?>
91
69
]]>
@@ -95,7 +73,7 @@ function return_bytes($val)
95
73
<![CDATA[
96
74
97
75
display_errors = 1
98
- register_globals = 0
76
+ opcache.enable_cli = 0
99
77
post_max_size = 8M
100
78
post_max_size+1 = 9
101
79
post_max_size in bytes = 8388608
@@ -126,9 +104,9 @@ post_max_size in bytes = 8388608
126
104
<function >ini_get</function > will return the exact string stored in the
127
105
&php.ini; file and <emphasis >NOT</emphasis > its <type >int</type >
128
106
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 .
132
110
</para >
133
111
</note >
134
112
<note >
@@ -145,6 +123,7 @@ post_max_size in bytes = 8388608
145
123
<simplelist >
146
124
<member ><function >get_cfg_var</function ></member >
147
125
<member ><function >ini_get_all</function ></member >
126
+ <member ><function >ini_parse_quantity</function ></member >
148
127
<member ><function >ini_restore</function ></member >
149
128
<member ><function >ini_set</function ></member >
150
129
</simplelist >
0 commit comments