Specifications
You can check the last modification date of a script with the getlastmod() (note the lack of
underscores in the function name) function, as follows:
echo date(“g:i a, j M Y”,getlastmod());
The function returns a UNIX timestamp, which we can feed to date() as we have done here,
to produce a human readable date.
Loading Extensions Dynamically
You can actually load extension libraries at runtime, if they are not compiled in, using the dl()
function.
This function expects as a parameter the name of the file containing the library. Under UNIX,
these will be filenames ending in
.so; under Windows, they will end in .dll.
An example of a call to dl() is
dl(“php_ftp.dll”);
This will dynamically load the FTP extension (on a Windows machine).
You shouldn’t specify the directory where the file lives: Instead, you should configure this in
the php.ini file. A directive called extension_dir will specify the directory where PHP will
look for libraries to dynamically load.
If you find you are having trouble dynamically loading extensions, also check your php.ini file
for the enable_dl directive. If it’s off, you won’t be able to dynamically load extensions.
Particularly if the machine you work on is not your own, this might be disabled for security
reasons. You also won’t be able to use dl() if PHP is running in safe mode.
Temporarily Altering the Runtime Environment
You can view the directives set in the php.ini file, or change them for the life of a single script.
This can be particularly useful, for example, in conjunction with the
max_execution_time
directive if you know your script will take some time to run.
You can access and change the directives using the twin functions ini_get() and ini_set().
Listing 21.2 shows a simple script that uses these functions.
LISTING 21.2 iniset.php—This Script Resets Variables from the php.ini File
<?
$old_max_execution_time = ini_set(“max_execution_time”, 120);
echo “old timeout is $old_max_execution_time <br>”;
Other Useful Features
C
HAPTER 21
21
OTHER USEFUL
FEATURES
453
26 7842 CH21 3/6/01 3:41 PM Page 453










