Home » Php » php – Uncaught Error: Call to undefined function stats_cdf_t()

php – Uncaught Error: Call to undefined function stats_cdf_t()

Posted by: admin February 25, 2020 Leave a comment


I have to calculate an Excel formula(F.DIST.RT) in PHP. but receiving an error.

F.DIST.RT(4, 2, 1)

As defined here:

How to&Answers:

As stated from the reference page, you need to install the correct php extension to call stats_cdf_t function, as it is not included inside php standard library.

You can use pecl to install it on your server.


In order to match the output of this function with Excel’s TDIST function, you must take 1 – the value. For example, for a two-tailed T-distribution for x=4 and degrees of freedom=2, the formula would be:

(1 - stats_cdf_t(4, 2, 1)) * 2


I installed PECL and Stat library in PHP to fix this problem.

sudo apt-get install php-pear
sudo apt-get install php7.4-dev
sudo pecl install stats-2.0.3

then added extension=stats.so to my php.ini
restart apache.