0

Originally, I had the problem that, although I had the same path by optical inspection, file_exists() returned true for one and false for the other. After spending hours narrowing down my problem, I wound up with the following code... (paths redacted)

$myCorePath = $modx->getOption('my.core_path', null, $modx->getOption('core_path').'components/my/');

$pkg1 = $myCorePath.'model/';
$pkg2 = MODX_CORE_PATH . 'components/my/model/';
$pkg3 = '/path/to/modx/core/components/my/model/';

var_dump($pkg1, $pkg2, $pkg3);

...and its output:

string '/path/to/modx/core/components/my/model/' (length=37)
string '/path/to/modx/core/components/my/model/' (length=78)
string '/path/to/modx/core/components/my/model/' (length=78)

So two versions, interestingly including simply writing the string down, apparently use wide characters (these worked, file_exists()-wise), while sadly my preferred variant uses narrow characters. I tried to research this but the only thing I wound up with told me that php has no such thing as wide strings. I also verified with a hex editor that all string constants really only take one byte per character in the php file.

phpinfo() tells me I have PHP Version 5.4.9, and I run on a 64 bit linux machine, fwiw. The manual was edited a week ago; is its info not accurate, or what's going on here?

Silly Freak
  • 4,061
  • 1
  • 36
  • 58

1 Answers1

0

I think it is caused by multibyte coding.

Vlad Bereschenko
  • 338
  • 1
  • 3
  • 11
  • Well, obviously two bytes are used per character, but why why should a simple string constant be encoded as anything else than ASCII? – Silly Freak Sep 12 '13 at 15:34