php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79739 inconsistent __DIR__ with accent
Submitted: 2020-06-26 07:46 UTC Modified: -
Votes:3
Avg. Score:4.0 ± 0.8
Reproduced:0 of 0 (0.0%)
From: lingtalfi at gmail dot com Assigned:
Status: Open Package: Apache2 related
PHP Version: 7.2.31 OS: mac osX mojave 10.14.6
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
46 - 5 = ?
Subscribe to this entry?

 
 [2020-06-26 07:46 UTC] lingtalfi at gmail dot com
Description:
------------
I create two files in my webroot directory www (served by apache 2.4.37):

- a.php
- b.php

In both I add this script:

```php
var_dump(__DIR__); exit;
```



The output from **a.php** is different than the one from **b.php** !!!

The output from a is this:

```html
string(88) "/Users/xxxxxxxxxxxxx/Documents/it/web/Komin>/service création/projets/jin_site_demo/www" 
```

While the output from b is this:


```html
string(89) "/Users/pierrelafitte/Documents/it/web/Komin>/service création/projets/jin_site_demo/www" 
```


I'm not sure where the problem comes from (php?, apache?, my mac?),
but there is obviously a problem as they should output the exact same string.


The problem comes from the accent (é) which is not encoded in the same manner,
I tried using the php binary (php -f a.php), and both scripts output identical output, which means that the problem only occur when using php with apache.


I'm just a php user (not php developer) so I don't have any patch, but hopefully, if it's a php problem, this post helps to fix it.










Test script:
---------------
var_dump(__DIR__); exit;


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2022-11-25 06:14 UTC] Betty3564oyle at gmail dot com
Erwin Moller's profile photo
Erwin Moller
unread,
Oct 9, 2013, 4:03:16 PM
to
Hello comp.lang.php,

How can PHP open files on the local filesystem that contain certain
characters, like umlauts, accents, etc?

I am currently developing on Win2008 with PHP 5.5.1 (CGI/FastCGI).
So the underlying filesystem is NTFS.

Files with names like the following are inaccessible:
ierländer.pdf
Eugčne.pdf
etc.
All files without these characters ARE readable.
(https://www.foremostpayonline.org/)github.com
 [2022-12-20 09:14 UTC] Harold151Harris at gmail dot com
What about creating an include file in the same directory as your app.

<?php return __DIR__; ?>
Use it like so:

$trueDIR = include('get_true_dir.php');
From what you posted above, this should work. Yes, it's a bit of a hacky workaround, but it is a workaround, and should work even on systems not suffering from this issue.
(https://www.aetna-medicare.org/)github.com
 [2023-05-26 05:44 UTC] dkjjdjksk45 at gmail dot com
That was so amazing. (https://www.prepaidgiftbalance.vip/)github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 18:01:28 2024 UTC