ConfigureWEB Posted January 22, 2013 Share Posted January 22, 2013 Hi, I have the following code in my application and it is not working on a certain VPS server and I have no idea why. Server: Linux - PHP Version 5.3.16 <?php define('PROJECTS_DIR', '../projects/'); // Gets project names from the projects folder. function projects() { $projects = glob(PROJECTS_DIR.'*', GLOB_ONLYDIR); for ($i=0; $i<count($projects); $i++) { $projects[$i] = basename($projects[$i]); } return $projects; } $projects = projects(); if (empty($projects)) { echo 'No projects found.'; } ?> The above code works fine on all other servers I tested but not on this one. No error, no output. What could be the reason? What should I check in phpinfo() or php.ini? Something to do with glob()? Thanks for any ideas. Quote Link to comment https://forums.phpfreaks.com/topic/273477-php-code-not-working-on-a-certain-server/ Share on other sites More sharing options...
requinix Posted January 22, 2013 Share Posted January 22, 2013 Could it be that it's working perfectly fine? Your script won't output anything if it works. Quote Link to comment https://forums.phpfreaks.com/topic/273477-php-code-not-working-on-a-certain-server/#findComment-1407430 Share on other sites More sharing options...
ConfigureWEB Posted January 22, 2013 Author Share Posted January 22, 2013 (edited) Could it be that it's working perfectly fine? Your script won't output anything if it works. Why? There is the echo 'No projects found.'; which should output when there is no projects in the "projects" folder, but it doesn't output anything. Edited January 22, 2013 by ConfigureWEB Quote Link to comment https://forums.phpfreaks.com/topic/273477-php-code-not-working-on-a-certain-server/#findComment-1407431 Share on other sites More sharing options...
ConfigureWEB Posted January 22, 2013 Author Share Posted January 22, 2013 The issue seems to be that glob() function is not working on that server. No idea if it is disabled or if it can be disabled somehow. If you have any ideas, please share with me. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/273477-php-code-not-working-on-a-certain-server/#findComment-1407436 Share on other sites More sharing options...
Christian F. Posted January 22, 2013 Share Posted January 22, 2013 If the echo doesn't print, and it's supposed to print when there's nothing inside the projects folder, then the logical step would be to assume that there is something inside of it. It is a boolean statement, after all, which gives you only one of two possible results. Do a var_dump () on the $projects variable, to see what kind of content is inside of it. Quote Link to comment https://forums.phpfreaks.com/topic/273477-php-code-not-working-on-a-certain-server/#findComment-1407440 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.