Generally the extension-wide global variables are actually configuration options set in the php.ini file, or perhaps in the Apache httpd.conf file. Adding such configuration options for your extension is easy. To add a test.my_ini_setting configuration variable, first follow the instructions for creating a global variable from the last slide. Then in your .c file add:

The arguments to STD_PHP_INI_ENTRY here are:

You can implement your own change notification handlers using PHP_INI_MH(), but here we will just use the default OnUpdateInt which basically just takes the string in the .ini file and does an atoi() on it. The other built-in handlers are OnUpdateReal(), OnUpdateBool(), OnUpdateString(), and OnUpdateStringUnempty().

After adding your STD_PHP_INI_ENTRY block to your .c file, in your MINIT function after the ZEND_INIT_MODULE_GLOBALS() add this:

And likewise, in your MSHUTDOWN function add:

And finally, you can optionally add this to your MINFO function: