Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98684 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60971 invoked from network); 30 Mar 2017 15:21:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2017 15:21:30 -0000 Authentication-Results: pb1.pair.com header.from=php@golemon.com; sender-id=softfail Authentication-Results: pb1.pair.com smtp.mail=php@golemon.com; spf=softfail; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain golemon.com does not designate 209.85.215.45 as permitted sender) X-PHP-List-Original-Sender: php@golemon.com X-Host-Fingerprint: 209.85.215.45 mail-lf0-f45.google.com Received: from [209.85.215.45] ([209.85.215.45:33268] helo=mail-lf0-f45.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8F/59-10047-6722DD85 for ; Thu, 30 Mar 2017 10:21:28 -0500 Received: by mail-lf0-f45.google.com with SMTP id h125so29455629lfe.0 for ; Thu, 30 Mar 2017 08:21:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=golemon-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=VQb9PALw2S14FPMnp3QB7rRkQmz5hFZdhzdfHf4K+v8=; b=Dtzwhc0GwPNeuhvqyC9ox1Np1yxwj1dfgAHan8YMSOstcM9WABSMYCRCkux29ytsHj vKGTVOJ2XKNKQUhHCagD94tnsGH/VhCw28BL6z05xlbzxZoerC2bHeiNUg7rtMi9J1Ww OVtp9eYRJjCYVbWZLhkZIYbtSeH99ans45KI6jNHfXrb0EuW90rVisr5QGmcOyGSb9j9 22/2hLu2Pp420NJy0OC3deNuaI10t3TvceMwIJlHzvOvnF6RW9hyFHeCBxq0dOl43xmr LXycgr+v8jKYtDA/TPfgjKwoasGbxqjoYq35yjwWFs9T/vgJOq3xQqQKfx2WeayzK6UJ WCog== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=VQb9PALw2S14FPMnp3QB7rRkQmz5hFZdhzdfHf4K+v8=; b=WL5yrv4uXLub6N4RLD/+SdEk4eAvbjIDOB1UFI80bVnaLXFSYjhmT3ARHGHWvb+ENw +6ufEDvC9cUXQ53MQp6kzxyZ7lg1Vbm1Z4FWNjAyWSZ0fuxyaq50K8xQNHpX/ZKB2EwQ OdFYin6yPIffhWRQrzrwLQAQQL4FEWDP0wXz6k2b7XgsLH4IqyBnX1I3NAU/dNMeik2b 7JkbpOfo5kJffQPSNNpZWqJNnjC13tx129SQrnRGfi6CDk0LlFlMuqsfXTdrYR7xJkkM YG4ceQ9oK8qWCo/ly6xBt9zwSEaZiqP51zsNPdTmM0xhCj1I99HMan0j9MnyEst4bSOB cRgw== X-Gm-Message-State: AFeK/H1MXZ2IXGTi0yvZdkBp8S2AbtQJd/anVykq0WXo5xqlBf5ztMVenzIXisjs5itQ2vvCT2xR3iLfOqQQxA== X-Received: by 10.28.136.81 with SMTP id k78mr4176286wmd.36.1490887284264; Thu, 30 Mar 2017 08:21:24 -0700 (PDT) MIME-Version: 1.0 Sender: php@golemon.com Received: by 10.223.179.24 with HTTP; Thu, 30 Mar 2017 08:21:23 -0700 (PDT) X-Originating-IP: [73.9.224.155] In-Reply-To: References: Date: Thu, 30 Mar 2017 10:21:23 -0500 X-Google-Sender-Auth: GWvpigW0E8Mgb-k1RxpcN_zoXZM Message-ID: To: Rasmus Schultz Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Directory separators on Windows From: pollita@php.net (Sara Golemon) 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?