php intl extension installation

王林
Release: 2023-05-06 15:25:07
Original
1555 people have browsed it

PHP intl extension installation

PHP intl is an official extension for internationalization and localization processing, including character encoding conversion, date and time formatting, currency formatting, text sorting, and language resource processing, etc. . This extension is essential when working with multilingual websites or applications.

This article will introduce how to install and enable the PHP intl extension, and provide installation steps for multiple operating systems (Windows, Mac and Linux) for readers' reference.

Installation prerequisites

Before installing the PHP intl extension, make sure your PHP version meets the following requirements:

  • PHP 5.3.0 or higher (PHP 7 Recommended)
  • ICU library 4.0 or higher

Install the ICU library

In most cases, the ICU library is already installed on the server by default. However, you can use the following command to check whether the ICU library has been installed:

icu-config --version
Copy after login
Copy after login

If the following error message is returned:

-bash: icu-config: command not found
Copy after login

Then you also need to install the ICU library. Here's how to install the ICU library on each operating system:

Installing the ICU library on Mac

On Mac, you can install the ICU library through Homebrew. Open the terminal and enter the following command:

brew install icu4c
Copy after login

After the installation is completed, you can check the version number through the following command:

icu-config --version
Copy after login
Copy after login

Install ICU library on Linux

Install ICU on Linux Libraries require the use of a package manager. For example, on Ubuntu, you can use the following command to install:

sudo apt-get install libicu-dev
Copy after login

On CentOS or RedHat, you can use the following command to install:

sudo yum install libicu-devel
Copy after login

Install the ICU library on Windows

In On Windows, you can download the ICU-for-Windows installation program from the ICU official website https://ssl.icu-project.org/download/. Please be careful to select the correct version (x86 or x64) when installing.

Install PHP intl extension

After installing the ICU library, next we need to install the PHP intl extension. The following is how to install it on each operating system:

Installing the PHP intl extension on Mac

To install the PHP intl extension on Mac you need to use the following command:

brew install php-intl
Copy after login

Installation completed After that, you need to restart the Apache or Nginx server:

sudo apachectl restart
Copy after login

or

sudo nginx -s reload
Copy after login

Installing the PHP intl extension on Linux

To install the PHP intl extension on Linux, you need to use the following command:

sudo apt-get install php-intl
Copy after login

or

sudo yum install php-intl
Copy after login

After installation, you need to restart the Apache or Nginx server:

sudo service httpd restart
Copy after login

or

sudo service nginx reload
Copy after login

Install PHP intl extension on Windows

To install the PHP intl extension on Windows, you need to edit the PHP php.ini file and add the following statement in the [PHP] section:

extension=php_intl.dll
Copy after login

After saving, you need to restart the Apache or Nginx server.

Test

After the installation is completed, you can test whether the PHP intl extension is successful by using the following code:

$fmt = new NumberFormatter( 'de_DE', NumberFormatter::DECIMAL ); $num = $fmt->parse( '1.234.567,89' ); echo $num;
Copy after login

If the normal output1234567.89means the extension is installed successfully .

Conclusion

The installation process for the PHP intl extension is relatively simple, but slightly different in different operating systems. This article describes the steps to install the PHP intl extension on Windows, Mac and Linux. I hope it will be helpful to readers.

The above is the detailed content of php intl extension installation. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!