Jump to content

[SOLVED] Constants Problem


Fadion

Recommended Posts

I am making a website for a client with a simple php/mysql custom cms. The problem i am facing is when using constants. They cant seem to work. Ex:

 

I have a config.php file where i put all the configuration constants

define('SITE_TITLE', 'My Webiste');

 

When echoing SITE_TITLE locally i get 'My Website' but on the shared host i just get 'SITE_TITLE' echoing. I can fix those by using variables but i would need to change a lot of code. Has anybody else faced this problem and if so how did u fix it?

 

Thanks in advance.

Link to comment
Share on other sites

How are you echo'ing the constant? Make sure you don't wrap the constant in quotes eg:

echo 'SITE_TITLE';
// OR
echo "SITE_TITLE";

The constant has to be on its own eg:

echo SITE_TITLE;

 

Prehaps check to see if the constant SITE_TITLE is defined first before using it:

if (defined('SITE_TITLE')) {
    echo SITE_TITLE;
}
else
{
    echo "'SITE_TITLE' does not exist";
}

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.