- Do you want to use the function: get_browser in php and the result of the function is empty?
- Using the get_browser function generates error messages ?:
Got error 'PHP message: PHP Warning: get_browser(): browscap ini directive not set in .../ipfail.org/public_html/... on line ...'
- Trying to activate the option in php.ini generates fatal or warnings errors ?:
... NOTICE: PHP message: PHP Warning: Cannot open 'extra/browscap.ini' for reading in Unknown on line 0
... NOTICE: PHP message: PHP Fatal error: Unable to start standard module in Unknown on line 0
- The function does not correctly recognize modern browsers?
Then I think you need to update the browscap.ini file or “install” this file on the server if it does not exist!
Here are the steps needed to solve this “problems” in ubuntu / debian server:
1). Locate the folder where php is installed
is usually in /etc/php/
and the functional version, in my case is in /etc/php/7.4/
But they can be found using the following commands in ubuntu server (in my case, ubuntu 20.04):
@ php -version PHP 7.4.13 (cli) (built: Nov 28 2020 06:24:59) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.13, Copyright (c), by Zend Technologies
@ php -a Interactive mode enabled php > phpinfo(); phpinfo() PHP Version => 7.4.13 System => Linux *** 5.4.0-1009-kvm #9-Ubuntu SMP Mon Apr 20 20:23:56 UTC 2020 x86_64 Build Date => Nov 28 2020 06:24:59 Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/php/7.4/cli Loaded Configuration File => /etc/php/7.4/cli/php.ini Scan this dir for additional .ini files => /etc/php/7.4/cli/conf.d Additional .ini files parsed => /etc/php/7.4/cli/conf.d/10-mysqlnd.ini, /etc/php/7.4/cli/conf.d/10-opcache.ini, /etc/php/7.4/cli/conf.d/10-pdo.ini, /etc/php/7.4/cli/conf.d/15-xml.ini,
From the displayed results we deduce that the active version for the installed php configuration is in the folder /etc/php/7.4/
2). Install the browscap.ini file
It is useful to install it in the folder /etc/php/7.4/mods-available
You must first download an updated version from browscap.org, only the special version of browscap.ini for PHP users only!:
@ sudo wget http://browscap.org/stream?q=PHP_BrowsCapINI
and rename the saved PHP_BrowsCapINI file as follows:
@ sudo mv 'stream?q=PHP_BrowsCapINI' browscap.ini
3) Enable the [browscap] option in the php.ini
,
in my case located in the folder /etc/php/7.4/fpm/
@ sudo nano /etc/php/7.4/fpm/php.ini
modify the file as follows:
[browscap] ; http://php.net/browscap ;browscap = extra/browscap.ini browscap = /etc/php/7.4/mods-available/browscap.ini
Save the change and restart the php service:
@ sudo service php7.4-fpm restart
or possibly restart the entire web-stak as follows:
for Apache:
@sudo apache2ctl restart
or if you use Nginx:
@sudo nginx -s reload
That was all, Happy Coding !
Related Posts
Leave a Reply
Your email address will not be published. Required fields are marked *
One Comment
Get last URL after following HTTP redirections in PHP – get_headers – ipFail
[…] valid User-Agent browser , otherwise some sites restrict […]