0

I am trying to store and retrieve data from my Database including some PHP Constants.

I have set the constant so:- define("COMPANY", "MyCompany");

I want to use other constants so I can change the values later down the line if I deploy the site elsewhere.

I have tried using php before the insert e.g. You can use <?=COMPANY?>" to keep your diary full and win more work...

But it doesn't work so stuck.

It simply ignores the constant completely.

I would appreciate some help, thanks

Your Common Sense
  • 156,878
  • 40
  • 214
  • 345
  • 2
    "But it doesn't work so stuck." - what does that mean? What **exactly** is not working? – Nico Haase May 04 '23 at 13:55
  • 1
    Can you give us the line in the code where you are trying to post? – tola May 04 '23 at 13:57
  • @NicoHaase when you do echo $text where $text contains `=COMPANY?>`, it doesn't output the COMPANY constant – Your Common Sense May 04 '23 at 13:58
  • Database has `You can use =COMPANY?>" to keep your diary full and win more work` in it or `You can use " to keep your diary full and win more work`? Also verify you have browser transformation turned off if viewing in phpmyadmin, or view page source if viewing on web page. `=COMPANY?>` would not render as browser would see it as an element. – user3783243 May 04 '23 at 14:01
  • 1
    @YourCommonSense that's obvious, as the constant is resolved on echoing. But James hasn't written anything about echoing – Nico Haase May 04 '23 at 14:02
  • 1
    The only way to concatenate a constant into a string is `"foo " . CONSTANT . " bar"`. There is no syntax for interpolating constants inside strings as if they were variables. `= statement ?>` is shorthand for `` which sends the result of the statement _to output_. – Sammitch May 04 '23 at 20:51

0 Answers0