Jump to content

PHP code not working on a certain server


ConfigureWEB

Recommended Posts

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.

  On 1/22/2013 at 8:16 AM, requinix said:

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.

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.