PHP - How to find out the encoding of a site.

  • Last updated: Nov 3, 2023
  • Views: 336
  • Author: Admin
PHP - How to find out the encoding of a site.

Hello colleagues.

In today's article we will talk about how to see how you have set the encoding on the site.

Sometimes you need to know how you have the encoding set on the site, but not everyone knows how to do this, and many novice web developers struggle with scribbles on the page, or when adding information to the database, the content turns into a bunch of incomprehensible characters. There are two ways to check which encoding you currently have on the site. The first way is to use the php function mb_internal_encoding(), and the second way is to use the php function phpinfo().

 

The content of the article:

  1. Function mb_internal_encoding().
  2. Function phpinfo().

 

1. Function mb_internal_encoding().

<?php
echo mb_internal_encoding();
?>

get encoding

Using the mb_internal_encoding() function, you can not only get the current encoding, but also set the encoding you need by passing it the encoding name as a parameter.


 

2. Function phpinfo().

<?php
phpinfo();
?>

get encoding

The phpinfo() function returns absolutely all information about the current PHP configuration. Among all the information that the function returns, the default_charset parameter is just responsible for what encoding you currently have installed.


 

Thank you all, I hope my article was of some help to you.

SIMILAR ARTICLES

YII2 defaultRoute - How to change default controller in template

YII2 defaultRoute - How to change default controller in template

Pure HTML/CSS search bar

Pure HTML/CSS search bar

HTML/CSS - Expandable Searchbar Animation

HTML/CSS - Expandable Searchbar Animation