I tried to run a Drupal 7 installation on my local environment which previously worked totally fine. I use Mac OS X. When requesting the website locally the browser shows:
Parse error: parse error in /Library/WebServer/Documents/.../xxx.module on line 7
Line 7 is
$variables['path'] = $base_url . "/sites/default/files/" . explode('public://',$file->uri)[1]
OR it returns an error with the code:
ERR_EMPTY_RESPONSE
The apache error file shows:
child pid 2114 exit signal Segmentation fault (11)
php -v returns
PHP 5.3.26 (cli) (built: Jul 7 2013 19:05:08) Copyright (c) 1997-2013 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
The code seems not to be wrong. It's exactly the same running on another machine.
Array dereferencing was added in PHP5.4. Your server has v5.3.26, so this
explode('public://',$file->uri)[1];
isn't valid syntax.
You either need to upgrade to 5.4 (Homebrew makes that easy), or change your code:
$parts = explode('public://',$file->uri);
$variables['path'] = $base_url . "/sites/default/files/" . $parts[1];