extension_loaded 


php128 apg

FINDS out whether an extension is loaded.



<?php

bool extension_loaded 
str $name )


where,

$name The name of the extension
  
?>

  $name   


The extension name.

This parameter is case-insensitive.





You can see the names of various extensions by using phpinfo()...

phpinfo apr

... or if you're using the CGI or CLI version of PHP you can use the -m switch to list all available extensions:



The result of this command will depend
of the configuration of your PHP CLI system

H:\php64\php>php -m

[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
filter
gd
gmp
hash
iconv
imap
intl
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_mysql
Phar
readline
Reflection
session
SimpleXML
sodium
SPL
standard
tokenizer
xml
xmlreader
xmlwriter
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache

Your results may differ from those shown here.


  1 EXERCISE   

<?php

$ext01 
'standard';

if(
extension_loaded($ext01))
{
    echo 
'The extension "' $ext01 '" is loaded!<br>';
}
else
{
    echo 
'The extension "' $ext01 '" is NOT loaded!<br>';
}

?>

 RESULT   

The extension "standard" is loaded!

  2 EXERCISE   

<?php

// The result of this exercise will depend
// of the configuration of your system

$ext02 'imagic';

if(
extension_loaded($ext02))
{
    echo 
'The extension "' $ext02 '" is loaded!<br>';
}
else
{
    echo 
'The extension "' $ext02 '" is NOT loaded!<br>';
}

?>