Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

const variable


spacegremlin

Recommended Posts

basicly a simple question, but i dont know.

I want to place TESTVARIABLE there, so i can place the value of that somewhere else.
but if i use this i got an error.
because if you would do this in a define command, it does work.


  const MODULE_CONTENT_I_TITLE_DESCRIPTION  = 'link "blablabla'.TESTVARIABLE.'" end';
  
thank you

    
    
    
    
    
    

Link to comment
Share on other sites

You can only use const in global or class context, not inside a function.  So if you have something like

function do_stuff() {
  const WHATEVER = 'whatever';
}

you'll get an error. 

You also can only do const with things that can be done at compile time.  So

function do_stuff() {
  return 'whatever';
}

const WHATEVER = do_stuff();

for anything that needs to be calculated at run time.  The define is done at run time, so it doesn't care about that. 

Always back up before making changes.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...