je suis arrivé ce codeProblème chaîne de conversion de chemin "/", ""
$ current_path = str_replace ('\', '/', getcwd()); // c: // xampp/htdoc
Pourquoi l'échec remplace-t-il '\' par '/' dans le répertoire? pourquoi est la raison et comment gérer ce problème?
EDIT Ce code permet de renvoyer le chemin (ou quelque chose comme ça) à utiliser avec la base HTML TAG.
$current_path = getcwd(); function get_basepath() { global $current_path; $current_path = str_replace('\\', '/', $current_path); // C:\xampp\htdocs\php\gettingstarted $cur_root = $_SERVER['HTTP_HOST']; // localhost $cur_docroot = $_SERVER['DOCUMENT_ROOT']; // C:/xampp/htdocs/ $cur_filepath = $_SERVER['SCRIPT_FILENAME']; // C:/xampp/htdocs/php/gettingstarted/index.php $filepath = str_replace($cur_docroot, '', $current_path); return "http://$cur_root/" . $filepath . "/"; // http://localhost/php/gettingstarted/index1.php }
oui, j'ai oublié à ce sujet. merci beaucoup – justjoe