strange thing with path - slash or backslash?

Hi all

while debbuging a 404 not found of an image file i noticed something strange

i ran this php builtin func to get cuurent path on runtime:

[size="4"]$curPath = getcwd ();

i got this value :

$curPath

"C:[color="#0000FF"]\[/color]xampp[color="#0000FF"]\[/color]htdocs[color="#0000FF"]\[/color]yii2[color="#0000FF"]\[/color]YES-‏‏basic-rbac-school"[/size]

and Yii::getAlias returnes this value:

[size=“4”]Yii::getAlias(’@webroot’);

"C:[color="#FF0000"]/[/color]xampp[color="#FF0000"]/[/color]htdocs[color="#FF0000"]/[/color]yii2[color="#FF0000"]/[/color]YES-‏‏basic-rbac-school"[/size]

one is with slashes and one with backslashes

what am i missing here?

Thanks in advance…

It is a Windows specific behavior of PHP.

http://php.net/manual/en/function.realpath.php

It is not only the case for "realpath" bat also for other functions that handle files and directories.

As a consequence, we can write a path in source code using "/" alone, stop worrying about the OS.

getcwd() returns literately the result of the getcwd sys_call depending on the OS. I would recommend you use DIR constant to figure out the directory path which returns very similar results to getcwd, let php handle all OS specific stuff internally.

for realpath function as suggested by softark you need to give it a path.