Home Backend Development PHP Problem php intl extension installation

php intl extension installation

May 06, 2023 pm 03:25 PM

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 output 1234567.89 means 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!

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

Java Tutorial
1670
14
PHP Tutorial
1274
29
C# Tutorial
1256
24