mirror of
https://github.com/Aviortheking/Blog_IMIE.git
synced 2025-04-22 19:02:10 +00:00
28 lines
601 B
PHP
Executable File
28 lines
601 B
PHP
Executable File
<?php
|
|
|
|
//function pour voir la fin d'un texte
|
|
function endsWith($haystack, $needle) {
|
|
$length = strlen($needle);
|
|
if ($length == 0) {
|
|
return true;
|
|
}
|
|
|
|
return (substr($haystack, -$length) === $needle);
|
|
}
|
|
|
|
function connect() {
|
|
$host = "127.0.0.1";
|
|
$db = "blog";
|
|
$user = "blog";
|
|
$pass = "blog";
|
|
$charset="utf8mb4";
|
|
|
|
$dsn = "mysql:host=$host;dbname=$db;charset=$charset";
|
|
try {
|
|
$pdo = new PDO($dsn, $user, $pass);
|
|
} catch (\PDOException $e) {
|
|
throw new \PDOException($e->getMessage(), (int)$e->getCode());
|
|
}
|
|
return $pdo;
|
|
}
|