// 2018-08-03T15:21:28+00:00$date = date_create_from_format(‘Y-m-d\TH:i:sT‘, ‘ 2018-08-03T15:21:28+00:00 ‘);echo date_format($date, ‘Y-m-d H:i:s‘); Le format mysql est bien Y-m-d H:i:s pour le type datetime /
Étiquette : php

PHP : Convertir un chaine (string) possédant des sauts de lignes en tableau (array)PHP : Convertir un chaine (string) possédant des sauts de lignes en tableau (array)
1er méthode si vous connaissez le caractére de séparation 2ème méthode si vous connaissez pas le caractére de séparation preg_match_all("/[\S ]+/", $monString, $match)print_r($match);

PHP FAILLE XSS ASTUCEPHP FAILLE XSS ASTUCE
Mettez cette fonction en début de code et cela devrait vous protéger un minimum // FILTERING VALUES FROM USER, PREVENTING XSS INJECTIONS if(!empty($_POST)) { function filter_xss(&$value) { if(is_array($value)) { array_walk_recursive($value,
PHP : fonction pour déterminer si un jour est un WEEKENDPHP : fonction pour déterminer si un jour est un WEEKEND
//Date in YYYY-MM-DD format.$dateToSet = '2020-02-08';//Output for testing purposes.if(isWeekend($dateToSet)){echo $dateToSet . ' it's a weekend.';} else{echo $dateToSet . ' it's on a weekday.';}function isWeekend($date){//Set this to FALSE until proven otherwise.$weekendDay
PHP : PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.))PHP : PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.))
PHP Warning: PHP Startup: Unable to load dynamic library ‘oci8_12c’ (tried: D:/project/php/ext/oci8_12c (The specified module could not be found.), D:/project/php/ext/php_oci8_12c.dll (%1 is not a valid Win32 application.)) Vérifier que vous

PHP : WINDOWS Call to undefined function ldap_connect()PHP : WINDOWS Call to undefined function ldap_connect()
Bien vérifier la configuration de votre php.ini avec « extension=ldap » bien décommenté et la présence de la dll « php_ldap.dll » dans le répertoire ext PHP. Ensuite veiller à ce que PHP soit

PHP : Fonction pour CURL (avec authentification Bearer si besoin)PHP : Fonction pour CURL (avec authentification Bearer si besoin)
Curl php avec authentification Bearer au besoin function callAPI($method, $url, $data ,$sessionIdToPut ){ $curl = curl_init(); switch ($method){ case "POST": curl_setopt($curl, CURLOPT_POST, 1); if ($data) curl_setopt($curl, CURLOPT_POSTFIELDS, $data); break; case
PHP : Effacer des vieux fichiersPHP : Effacer des vieux fichiers
function deleteOldFile( $filename) { // in seconde ici 600 secondes soit 10 minute if (time()-filemtime($filename) > 600) { unlink($filename); } }
PHP : récupérer l’IP d’un utilisateurPHP : récupérer l’IP d’un utilisateur
function getIP() { if (isset($_SERVER["HTTP_CF_CONNECTING_IP"])) { $_SERVER['REMOTE_ADDR'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; $_SERVER['HTTP_CLIENT_IP'] = $_SERVER["HTTP_CF_CONNECTING_IP"]; } $client = @$_SERVER['HTTP_CLIENT_IP']; $forward = @$_SERVER['HTTP_X_FORWARDED_FOR']; $remote = $_SERVER['REMOTE_ADDR']; if(filter_var($client, FILTER_VALIDATE_IP)) { $ip = $client; } elseif(filter_var($forward,
PHP : transmettre un array PHP dans un JavascriptPHP : transmettre un array PHP dans un Javascript
json_encode($MonArrayPhp) Documentation offciel : https://www.php.net/manual/fr/function.json-encode.php exemple : <?php $MonArrayPhp = array("test","test01","test02","test03"); ?> <script> alert('<?php echo json_encode($MonArrayPhp)?>') ; </script>