Scripts et Programmation

HTML + PHP + MYSQL : Modèle de page UTF-8

Table des matières

Introduction



Ci-dessous, un modèle de page PHP pour avoir le tout encodé en UTF8, en passant de la base SQL, à PHP sans oublier HTML.
Hé oui, j'en ai marre de trouver les fonctions un peu partout sur le net, donc ici, je récapitule tout.


Le modèle de page




Code PHP :
<!DOCTYPE html>
<?php
header( 'content-type: text/html; charset=utf-8' );
// SQL CREER BASE : CREATE DATABASE `ma_base` DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
$conn = mysqli_connect('localhost', 'root', 'mdp', 'ma_base');
$conn->set_charset("utf8");
?>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>
 
    <body>
 
 
    </body>
</html>
<?php
mysqli_close($conn);
?>
Cette page a été vue 10349 fois