Blog_IMIE/project/assets/php/functions.php
2019-02-18 16:37:50 +01:00

32 lines
625 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 = "localhost";
$db = "blog";
$user = "root";
$pass = "root";
$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;
}
function getBDD() {
}