Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98685 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 63810 invoked from network); 30 Mar 2017 15:45:40 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2017 15:45:40 -0000 Authentication-Results: pb1.pair.com header.from=kris.craig@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=kris.craig@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.218.51 as permitted sender) X-PHP-List-Original-Sender: kris.craig@gmail.com X-Host-Fingerprint: 209.85.218.51 mail-oi0-f51.google.com Received: from [209.85.218.51] ([209.85.218.51:34782] helo=mail-oi0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 97/E9-10047-0282DD85 for ; Thu, 30 Mar 2017 10:45:38 -0500 Received: by mail-oi0-f51.google.com with SMTP id o67so35094672oib.1 for ; Thu, 30 Mar 2017 08:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=oke6E8mCyALaNKz9COvHLijaxgMYMAbvOG5uxZkWaQk=; b=CbL3/87PK0cNRTvQ9tWre0ImnF0K1tbSBcGhrLOFYlGIyiIMD0g1aOIf6h1+vcNyeP bcYyT5Br/RZx+hv8JH87oEs/YaXNWITtOO3g6EXLmb0VbWhCTNZOfzijoIqEGVv8lFyx vJEnOhP6C1bM9OQvLhaSEnOu1Tesyz1GSuYNDIqjKeouGF8uo4DtfJUgy1oH2MY+Z0/D 0bjBL9HoMG2upii6d7VfkzBecgsl/CJ4q4Rjj8VDvvKYWBOnQwHhYYv04nS+1RmLgp6C 6KOBBXbyHzBj5llKkl/m33Oj8hpAz5eSZX0adjJIuYIcmpZuyTSZtgrxIQezy9s0fhFi TvHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=oke6E8mCyALaNKz9COvHLijaxgMYMAbvOG5uxZkWaQk=; b=QmDlSKMr5KqkBC66yfJdJ0PaulNf2UeKpMyZSdwPSRsu0X2rjCPV6DjtyXwwXwzb4m RTg+VTVi3VnYL4xBKYG7g+tDObe7G2wHfj8vC9qfygfiwgrXgMk2VXIMmudwQn9v10Mp Ud2khQfRlFUxkpSNZbQ48POebNVZtbO2vmxq9ESDvvW9MH0ZSUbrE3M11wPF8pZj9Yms dx9+I9HGJPUWj6wzV7VIqMYCETf5Hqhx+IgBAyKa9sTOW3MkPfjAnXR1xSG1HCSmAqHw h3THUY35R9m7PjhOb/JsEbAxghdv0GPMNGfhGs027qe8zU8hcyTJBN7v/JVVi2sx5A1+ pXKA== X-Gm-Message-State: AFeK/H2ZJ+NvPweopYvJ3NkiJCh3Hc8nSR4CvpYKu27MltOBUP9et4Md+k8rpE9ZPVeFrsfGcW8RgehHZXEbxg== X-Received: by 10.157.31.6 with SMTP id x6mr167700otd.143.1490888732648; Thu, 30 Mar 2017 08:45:32 -0700 (PDT) MIME-Version: 1.0 Received: by 10.202.73.194 with HTTP; Thu, 30 Mar 2017 08:45:31 -0700 (PDT) Received: by 10.202.73.194 with HTTP; Thu, 30 Mar 2017 08:45:31 -0700 (PDT) In-Reply-To: References: Date: Thu, 30 Mar 2017 08:45:31 -0700 Message-ID: To: Sara Golemon Cc: Rasmus Schultz , PHP internals Content-Type: multipart/alternative; boundary=001a1134f9b24f2bb8054bf49520 Subject: Re: [PHP-DEV] Directory separators on Windows From: kris.craig@gmail.com (Kris Craig) --001a1134f9b24f2bb8054bf49520 Content-Type: text/plain; charset=UTF-8 On Mar 30, 2017 8:21 AM, "Sara Golemon" wrote: > > My first thought is UNC paths. On windows a file server share is > denoted by \\host\share . if you combine that with relative paths > produced from PHP, you end up in the dubious situation of > "\\host\share/path/to/file" <--- wat? > > Overall, it smells of magic. > > -Sara > > On Thu, Mar 30, 2017 at 8:25 AM, Rasmus Schultz wrote: > > Today, I ran into a very hard-to-debug problem, in which paths (to SQL > > files, in a database migration script) were kept in a map, persisted to a > > JSON file, and this file was moved from a Windows to a Linux file-system - > > because the paths on the Linux system had forward slashes, the files > > appeared to be missing from the map. > > > > Related questions are very commonly asked by Windows users, indicating that > > this is a common problem: > > > > http://stackoverflow.com/questions/14743548/php-on-windows-path-comes-up-with-backward-slash > > http://stackoverflow.com/questions/5642785/php-a-good-way-to-universalize-paths-across-oss-slash-directions > > http://stackoverflow.com/questions/6510468/is-there-a-way-to-force-php-on-windows-to-provide-paths-with-forward-slashes > > > > The answers that are usually given (use DIRECTORY_SEPARATOR, use > > str_replace() etc.) is that by default you automatically get cross-platform > > inconsistencies, and the workarounds end up complicating code everywhere, > > and sometimes lead to other (sometimes worse) portability problems. > > > > The problem is worsened by functions like glob() and the SPL directory/file > > traversal objects also producing inconsistent results. > > > > Returning backslashes on Windows seems rather unnecessary in the first > > place, since forward slashes work just fine? > > > > Might I suggest changing this behavior, such that file-system paths are > > consistently returned with a forward slash? > > > > Though this is more likely to fix rather than create issues, this could be > > a breaking change in some cases, so there should probably be an INI setting > > that enables the old behavior. > > > > Thoughts? > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > Another option would be to create a function that converts all slashes in a given input string to whatever the directory seperator should be on that platform. This way, devs wouldn't have to deal with bulky aliases like DIRECTORY_SEPERATOR cluttering up their code. For example: The above would output "/some/directory" on Linux and "\some\directory" on Windows. --Kris --001a1134f9b24f2bb8054bf49520--