-1

I have a problem in a line of my code. On localhost it works smoothly. On host, it displays this error:

Parse error: syntax error, unexpected ':' in (..../library.php) on line 94

This is line 94:

$Pay['environment'] = getenv('PAY_ENV') ?: self::PAY_ENV;

PHP Version 5.2.17. Any help would be appreciated.

Rasclatt
  • 12,498
  • 3
  • 25
  • 33
Darklee
  • 3
  • 1
  • 3

1 Answers1

1

The abreviated ?: syntax was not added until PHP 5.3. You will need to use the full ternary expression. Something like this should work.

$Pay['environment'] = getenv('PAY_ENV') ? getenv('PAY_ENV') : self::PAY_ENV;

http://php.net/manual/en/language.operators.comparison.php#language.operators.comparison.ternary

Jason Desrosiers
  • 22,479
  • 5
  • 47
  • 53