0

I need to make an HTTP call from a PHP script. I've tested it on my personal domain (running PHP 5.3.29) and it's all ok. When I've moved it on my customer domain (running PHP 5.3.10) the script starts having some problem.

In particular, this is the code that generate the error:

function BuildPlayFabHttpHeaders($i_PlayFabSecretKey) {

    $headers = [
        "Content-Type: application/json",
        "X-SecretKey: $i_PlayFabSecretKey"
    ];

    return $headers;
}

I think the problem is with that kind of declaration, but I'm not a php expert. Can anyone help me to get this running on PHP 5.3.10?

Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
erre
  • 39
  • 2
  • 6

1 Answers1

1

This wouldn't have worked on PHP 5.3.29 since the short array syntax [..] was introduced in PHP 5.4.

For anything under 5.4, you must use:

array(
    key  => value,
    key2 => value2,
    key3 => value3,
    ...
)

My assumption is your tests weren't actually using the PHP 5.3.29 binary but some other version installed on the system.

Devon Bessemer
  • 34,461
  • 9
  • 69
  • 95
  • Thanks Devon, you were right. I have changed syntax and it works! Only one thing, on my domain dashboard (I've bought it on Aruba) I see PHP version: 5.3.29. So I believe that 5.3.29 supports [..] syntax. Anyway, thank you again. – erre Dec 13 '17 at 20:00