Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:98678 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 47136 invoked from network); 30 Mar 2017 13:25:10 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 30 Mar 2017 13:25:10 -0000 Authentication-Results: pb1.pair.com header.from=rasmus@mindplay.dk; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=rasmus@mindplay.dk; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mindplay.dk from 74.125.83.47 cause and error) X-PHP-List-Original-Sender: rasmus@mindplay.dk X-Host-Fingerprint: 74.125.83.47 mail-pg0-f47.google.com Received: from [74.125.83.47] ([74.125.83.47:34916] helo=mail-pg0-f47.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 21/07-10047-2370DD85 for ; Thu, 30 Mar 2017 08:25:06 -0500 Received: by mail-pg0-f47.google.com with SMTP id 81so39867454pgh.2 for ; Thu, 30 Mar 2017 06:25:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mindplay-dk.20150623.gappssmtp.com; s=20150623; h=mime-version:from:date:message-id:subject:to; bh=9eQfBUTvFKT65JVTeMykeNMC2rqZmhDTbFL8i1XiKx0=; b=1Wq+W7vsmuECS3wkBP7jF/4duTzFC4CEuETV1otBGaHzyxpRaOlUBwjOAKPBQA2yb7 +cy1YAfYIgtFbL0ButZtSNJ3vY7isRKzIQeYiOT81rYKHI/3LFFVJY7/v4Hy2wfL2yTs ByMAUqoqzqkdkTiwMlWWpqMtfzgKdhJqfGUXd4aHC4sdPCn5fO0lr70YLX0hovetEZ1o Sh0RsSKWaVcwwGrgpBgwcAOqxav+jqs5KkQ0+BHxhrCuYQqcGHKtOpnrxwFfXiuB8N9O aJkeLB1gDl/9+UhkAMSHd+sorcM91XMldXfVcXIXDX6wPZVomOJURtpVmGk3ElmCF0Lx GVEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=9eQfBUTvFKT65JVTeMykeNMC2rqZmhDTbFL8i1XiKx0=; b=MQHl4w5CGHQXHOZk7585qZGzde0N/dlcKMw9JFqSBDLJgxJt6bRZMDjpoNLFNPGDDx fDKGvK6iX2K+SXUq5A36JFy7UpjhVS4cCK2cq3/hcId/TnyiA1S9sgxaYpYEbbjEdJ0y MsP16urM7U/uYicN85Cug2zcN6JFWUAgptSIZSzN8fSo4XK1iaN5c7CCBAgj1ofVtY7P f7OlY1t4BWN2E+lOWqEqh8i0pIhUFc1OYfF7IZp1BmlFZnMw9sOYAF6eStoUuMFKgapx 6n53ug30OVQdNEv380YGEAKtiX/4qUdbgiVg3NPc7RBThCkLAgXxFWxhJ3STQ8aAzjvl +3RA== X-Gm-Message-State: AFeK/H0KAcEUyhLmLUJSB6l1PwtMVt8fjYsj76Bz4dpS4Y6zAyLNtO35k5WffEIDt/1Jjv6arjGqCL7KaHgyfQ== X-Received: by 10.84.136.34 with SMTP id 31mr7273803plk.52.1490880303387; Thu, 30 Mar 2017 06:25:03 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.145.150 with HTTP; Thu, 30 Mar 2017 06:25:02 -0700 (PDT) Date: Thu, 30 Mar 2017 15:25:02 +0200 Message-ID: To: PHP internals Content-Type: multipart/alternative; boundary=94eb2c11966ce2f612054bf29e17 Subject: Directory separators on Windows From: rasmus@mindplay.dk (Rasmus Schultz) --94eb2c11966ce2f612054bf29e17 Content-Type: text/plain; charset=UTF-8 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? --94eb2c11966ce2f612054bf29e17--