php - What is causing the syntax error in this case? -


so class starts out like

final class mywordpresssite {      const rooturl = 'http://mywebsite/mysubsite';     const themerooturl = self::$rooturl . '/wp-content/themes/allytics_theme';      function getrooturl ( )      {         return self::rooturl;     } 

and . in self::$rooturl . '/wp-content/themes/mytheme'; being flagged

syntax error: unexpected token '$rooturl'

any idea why? looks right me. installed php syntax highlighter , it's possible incorrectly flagging dot.

quoting php docs

the value must constant expression, not (for example) variable, property, result of mathematical operation, or function call.

const themerooturl = self::$rooturl . '/wp-content/themes/allytics_theme'; 

doesn't obey restriction:

self::$rooturl doesn't exist, because static variable reference, not reference defined constant, should referenced instead self::rooturl

and use of concatenation operation (not supported prior php 5.6.0)


Comments