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.

Link to comment
Share on other sites

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 by ConfigureWEB
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.