Skip to content

Instantly share code, notes, and snippets.

@samartioli
Created June 24, 2013 11:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samartioli/5849302 to your computer and use it in GitHub Desktop.
Save samartioli/5849302 to your computer and use it in GitHub Desktop.
hhvm [HipHop VM v2.1.0-dev (rel)] syntax error, unexpected $end, expecting TC_DOLLAR_CURLY or TC_QUOTED_STRING when executing parse_ini_file. Issue occurs when an ini value ends with a dollar sign: somekey = "value$" but does not error if the dollar sign is in the middle of the string: anotherkey = "value$value"
<?php
$filename = 'test.ini';
$iniArray = parse_ini_file($filename, true);
var_dump($iniArray);
[global]
fonts.trackingUrl = "https://fast.fonts.com/t/1.css?apiType=css&projectid=123"
serviceCache.1.cacheable = "true"
anotherkey = "value$value"
somekey = "value$"
@samartioli
Copy link
Author

Output:

$ php loadConfig.php 
array(1) {
  ["global"]=>
  array(4) {
    ["fonts.trackingUrl"]=>
    string(56) "https://fast.fonts.com/t/1.css?apiType=css&projectid=123"
    ["serviceCache.1.cacheable"]=>
    string(4) "true"
    ["anotherkey"]=>
    string(11) "value$value"
    ["somekey"]=>
    string(6) "value$"
  }
}
$ hhvm loadConfig.php 
syntax error, unexpected $end, expecting TC_DOLLAR_CURLY or TC_QUOTED_STRING or '"' in test.ini on line 7

bool(false)

@samartioli
Copy link
Author

Output with dollar sign escaped ( somekey = "value$" ) :

$ php loadConfig.php 
array(1) {
  ["global"]=>
  array(4) {
    ["fonts.trackingUrl"]=>
    string(56) "https://fast.fonts.com/t/1.css?apiType=css&projectid=123"
    ["serviceCache.1.cacheable"]=>
    string(4) "true"
    ["anotherkey"]=>
    string(11) "value$value"
    ["somekey"]=>
    string(6) "value$"
  }
}
$ hhvm loadConfig.php 
array(1) {
  ["global"]=>
  array(4) {
    ["fonts.trackingUrl"]=>
    string(56) "https://fast.fonts.com/t/1.css?apiType=css&projectid=123"
    ["serviceCache.1.cacheable"]=>
    string(4) "true"
    ["anotherkey"]=>
    string(11) "value$value"
    ["somekey"]=>
    string(6) "value$"
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment