|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2020-06-25 10:22 UTC] bugreports2 at gmail dot com
[2020-06-25 10:32 UTC] david dot hlavati at gmail dot com
[2020-06-25 10:41 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2020-06-25 10:41 UTC] cmb@php.net
[2020-06-25 11:34 UTC] david dot hlavati at gmail dot com
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 22:00:02 2025 UTC |
Description: ------------ First: it's possible that it's a normal behavior and I just don't know about it. php 7.4.7 - maybe not version related backstory: So I would like to get a bunch of maintenance classes and initialize them dynamically and I'm using the glob function for this as it's written in the test script section. This works on windows 10, however it returns with nothing on CentOS7. Forward slashes are fine in both cases, but maybe conventionally it should work the same on both systems - again; it's maybe a normal behavior. And - this is actually absolutely irrelevant, but - the forward slash solution doesn't work for creating the classes dynamically - unless if I replace the slashes before creating the classes. File structure: The targeted classes I would like to locate with the glob function are here: `common\\queue\\tasks\\maintenance\\` The script is running from here: `common\\queue\\` Test script: --------------- ``` // maintenance classes are located here $path = 'common\\queue\\tasks\\maintenance\\'; // only for testing purpose I'll store the classes here $classes = []; // this script file is in this path: `common\\queue\\whatever.php` foreach (glob(__DIR__ . "\\..\\..\\{$path}*.php") as $location) { $maintenanceClass = $path . basename($location, '.php'); $classes[] = $maintenanceClass; // the line below is just an example as I would like to use this (new $maintenanceClass)->initTask(BaseModel::getConfig('maintenanceFrequency')); } print_r($classes, true); ``` Expected result: ---------------- for example - if these files are on the desired place place: Array ( [0] => common\queue\tasks\maintenance\ActivatorMaintenance [1] => common\queue\tasks\maintenance\CartMaintenance [2] => common\queue\tasks\maintenance\EventLogMaintenance ) Actual result: -------------- Array ( )