WordPress.org

Make WordPress Core

Ticket #13575: 13575.php

File 13575.php, 558 bytes (added by hakre, 3 years ago)

ini_set(), ini_get() and ini_restore() php example

Line 
1<?php
2/**
3 * ini_get() and ini_set() usage
4 *
5 * (php example)
6 */
7$varname = 'memory_limit';
8
9$new = '42M';
10
11$initial = ini_get($varname);
12
13printf("initial value: \"%s\"\n", $initial);
14
15printf("new value: \"%s\"\n", $new);
16
17$old = ini_set($varname, $new);
18
19if (false === $old) {
20        printf("Error setting new value, exiting.");
21        return;
22}
23
24printf("old value: \"%s\"\n", $old);
25
26$current = ini_get($varname);
27
28printf("current value: \"%s\"\n", $current);
29
30ini_restore($varname);
31
32$original = ini_get($varname);
33
34printf("original value: \"%s\"\n", $original);
35