Netbeans IDE (or any) getting rid of CONSTANT

Hi there after a few years abscence, Ive picked up the Netbeans IDE and trying to sort out an Ecart PHP code thats giving me problems.

Heres the code:
define(‘FS_DIR_HTTP_ROOT’, rtrim(str_replace("\", ‘/’, realpath($_SERVER[‘DOCUMENT_ROOT’])), ‘/’));

This code I feel is erroneous as its used to define another CONSTANT and the other constant already has the same path info.

In real life the code works fine on a non temporary web host directory, but goes ape if temporary url and wont work under debug with netbeans due to same directory issues which I’d like to sort for the author.

In the code there are over 200 instances of the FS_DIR_HTTP_ROOT which are leading to issues. I would like to leave the instances in place with a substitution.
Is this possible ? reason I dont want to remove all 200 instances and have to reinstate them.

BTW I thought in the IDE I might be able to assign a null to the constant, but cant figure out how to do that.

Kindest regards,
Alistair.

Well, not really sure what you are attempting to do with the code. But, let’s walk thru it…

First, realpath($_SERVER[‘DOCUMENT_ROOT’]) takes the root folder of the current document which would be
in the form something like: “…\root\folder…\folder\etc”…

Next, str_replace("\", ‘/’,$path) removes any backwards slashes turning them into forward slashes. This is
normally done if the server might be a Windows server and not Linux or Apache. Server “rewrites” might
mess this up at times.

But, “realpath()” function is not case sensitive and may mess up the results depending on what you are trying
to do. Here is the PHP.net page for this: http://php.net/realpath

If you are just trying to get the address of the current page, you could just use the getcwd() function. It can
be found here: http://php.net/manual/en/function.getcwd.php

Lastly, to define some variable as null, it depends on how it is used. If you are simply wanting to define it as a
string to be placed at the beginning of a folder name to create a full path, you just need to define it as “” or ‘’.
Something like; DEFINE(‘FS_DIR_HTTP_ROOT’, ‘’); Then, wherever it is used it is just nothing…

Hope that helps!

Oh, also, by the way, temporary folders are not always usable by code. They do not always have the correct
permissions set up to allow your code to access them. That might be your issue with them.

Sponsor our Newsletter | Privacy Policy | Terms of Service