PHP Quick Tip: How to check loaded extensions on CLI

Posted on

In this article we will learn about some of the frequently asked Php programming questions in technical like PHP Quick Tip: How to check loaded extensions on CLI. When creating scripts and web applications, error handling is an important part. If your code lacks error checking code, your program may look very unprofessional and you may be open to security risks. Error handling in PHP is simple. An error message with filename, line number and a message describing the error is sent to the browser. This tutorial contains some of the most common error checking methods in PHP. Below are some solution about PHP Quick Tip: How to check loaded extensions on CLI.

Suppose we have PHP installed on our machine and we want to quick check what extensions loaded on our PHP. Plus you just want to know through CLI. It’s easy.

Usually I just type this.

php -i
Enter fullscreen mode

Exit fullscreen mode

It will display complete information about PHP and all its configuration. It is similar like we call phpinfo() function.

The second is typing this command.

php -r "print_r(get_loaded_extensions());"
Enter fullscreen mode

Exit fullscreen mode

It will display loaded extensions only. The result example is like below.

Array
(
    [0] => Core
    [1] => date
    [2] => libxml
    [3] => openssl
    [4] => pcre
    [5] => zlib
    [6] => filter
    [7] => hash
    [8] => pcntl
    [9] => Reflection
    [10] => SPL
    [11] => sodium
    [12] => session
    [13] => standard
    [14] => mysqlnd
    [15] => PDO
    [16] => xml
    [17] => bcmath
    [18] => calendar
    [19] => ctype
    [20] => curl
    [21] => dom
    [22] => mbstring
    [23] => fileinfo
    [24] => ftp
    [25] => gd
    [26] => gettext
    [27] => iconv
    [28] => igbinary
    [29] => imap
    [30] => json
    [31] => exif
    [32] => msgpack
    [33] => mysqli
    [34] => pdo_mysql
    [35] => Phar
    [36] => posix
    [37] => readline
    [38] => shmop
    [39] => SimpleXML
    [40] => sockets
    [41] => sysvmsg
    [42] => sysvsem
    [43] => sysvshm
    [44] => tokenizer
    [45] => wddx
    [46] => xmlreader
    [47] => xmlwriter
    [48] => xsl
    [49] => memcached
    [50] => Zend OPcache
)
Enter fullscreen mode

Exit fullscreen mode

Thank you and I hope you enjoy it.



Credits

Leave a Reply

Your email address will not be published. Required fields are marked *