different outputs of the function glob in different linux distro

General discussions related to php

Moderators: egami, macek, gesf

Post Reply
eltercera
New php-forum User
New php-forum User
Posts: 1
Joined: Wed Aug 01, 2018 6:59 pm

Wed Aug 01, 2018 7:21 pm

Hello everyone, I'm curious to understand why the following happens.

In Centos7 using the packages https://webtatic.com/packages/php56/

Code: Select all

# php -v
PHP 5.6.36 (cli) (built: May 18 2018 04:51:01) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
# php -a
Interactive shell

php > print_r(glob('/usr//local/*'));
Array
(
    [0] => /usr//local/bin
    [1] => /usr//local/etc
    [2] => /usr//local/games
    [3] => /usr//local/include
    [4] => /usr//local/lib
    [5] => /usr//local/lib64
    [6] => /usr//local/libexec
    [7] => /usr//local/sbin
    [8] => /usr//local/share
    [9] => /usr//local/src
)
In Alpine linux using distro packages:

Code: Select all

# php -v
PHP 5.6.36 (cli) (built: Apr 28 2018 21:08:16) 
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
/ # php -a
Interactive shell

php > print_r(glob('/usr//local/*'));
Array
(
    [0] => /usr/local/bin
    [1] => /usr/local/lib
    [2] => /usr/local/share
)
In alpine the output of glob function remove the extra path separator between "usr" and "local".
Why is the string normalized in alpine and not in centos7?
Is it a specific configuration in the php.ini or a build-time configuration?

Post Reply