I transferred a site to another server and I'm getting this error and I can not find the solution.
I have a configure.php file which as a list of DEFINE() functions. For example;

define('TEST', 'This is a test');

Then on my homepage, the first line on the page includes the configure.php. On the home page, if I do

echo TEST;

I get this error

PHP Notice: Use of undefined constant TEST - assumed 'TEST'

I do not understand this. I have access to the php.ini file, but I can not see anything wrong. Here is the phpinfo()
http://www.vicsnatural.net/test.php

Does anyone have any ideas? I know it has to do with a setting, I'm just not sure which. Thank you for any help!

    Also, the include() path on the home page is correct and does load the file.

      Have you tried using require() instead of include() to see if it's simply not finding the include file and silently error out on you?

      If that's not it, you aren't by any chance including it via HTTP instead of via a local file system path?

        You'd need to show us your actual code. If you cannot, can you make a reduced test case? To clarify, are you saying that exactly this exhibits the problem?

        define.php

        <?php
        define( "TEST","this is a test" );

        test.php

        <?php
        include "define.php";
        print TEST;

        Also, how do you know that your configure script is being included successfully? What have you done to confirm this?

          tried both include and require

          traq;11036937 wrote:

          You'd need to show us your actual code. If you cannot, can you make a reduced test case? To clarify, are you saying that exactly this exhibits the problem?

          define.php

          <?php
          define( "TEST","this is a test" );

          test.php

          <?php
          include "define.php";
          print TEST;

          Also, how do you know that your configure script is being included successfully? What have you done to confirm this?

          I echoed a statement on the configure.php file and it output when I can the home page.

            Wstar;11036941 wrote:

            tried both include and require

            I echoed a statement on the configure.php file and it output when I can the home page.

            Just note that per my comment above about including via http uri instead of a local file system path, that would still happen, but the constant definition would be local to that script only (run separately by the web server) and still unknown to the calling script -- just in case that's the situation.

              Wstar;11036941 wrote:

              I echoed a statement on the configure.php file and it output when I can the home page.

              …and did you try the code I posted? does it also demonstrate the problem?

              If not, then we can look for a difference between this and the actual code you are using. (@'s suggestion seems likely.)

                I agree, NogDog's diagnosis sounds accurate. You can also make another test using a variable definition instead of a constant defined with define(). That should convince you that the problem is not with the definition of the constant, but with the way you are specifying the name of the file to be included.

                  Write a Reply...