0

Right now my webhost only has a sever with the max php number of 5.2. I didn't realize this and coded entirely on Xamp with a 5.3.1 server. Is there any sort of php script or something that will allow me to run 5.3 code on a 5.2 server. One of the particular lines im having trouble with is this:

$files = array_diff( scandir( __DIR__ . '/data' ), array('.','..') );
require __DIR__ . '/views/view_index.php';

At about that line the php just doesn't read, and has issues. The view_index.php works on its own, but the line above doesn't seem to be working, since I need to pass that variable to read in some file names into a dropdown selector. Although, I have more problems, most of which will take a long time to solve. Is there any sort of script made to ease this process. I have been looking around and couldn't find any.

4
  • There is another post on this, that might help you: stackoverflow.com/questions/4693575/… Commented Jul 19, 2012 at 18:58
  • 1
    You should consider changing the hosts: Even PHP5.4 is out ... Commented Jul 19, 2012 at 18:58
  • I know I tried, the problem is I am not exactly in charge of changing the webhost, and I asked the guy who is and he paid for two years... sigh Commented Jul 19, 2012 at 18:59
  • Change your xamp environment to 5.2 and fix your app to run in 5.2. Then you can migrate use it on your 5.2 host. Depending on the complexity of your app it shouldn't be too hard to convert it to 5.2 compat. Commented Jul 19, 2012 at 19:05

1 Answer 1

1

As for the particular __DIR__ problem you wrote, you can do a search & replace and change it to this everywhere:

dirname(__FILE__)

this should result in the same as __DIR__.

Sign up to request clarification or add additional context in comments.

4 Comments

Or just define('__DIR__', dirname(__FILE__)) so that you don't have to change a ton of code...
@AlexHowansky NO, bad, that would define __DIR__ as the same directory no matter where you used it. There is a reason they are called 'magic' constants: us.php.net/manual/en/language.constants.predefined.php
I am a little new to this function, but when i try to edit it like the documentation says, it only shows me the files in the root directory, but I need to get the files in the directory one down from it called data
@user: Yes, this is a result of the effect noted in Aknosis' comment -- __DIR__ changes depending on what file you're in, and my define wouldn't. So... nevermind. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.