0

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.

2
  • What about the code on line 7 ?? ...maybe you are missing some php extension or something like that Commented Dec 21, 2013 at 22:16
  • That is line 7: $variables['path'] = $base_url . "/sites/default/files/" . explode('public://',$file->uri)[1]; Commented Dec 21, 2013 at 22:37

2 Answers 2

2

Why don't you use file_create_url.

$variables['path'] = file_create_url($file->uri);
Sign up to request clarification or add additional context in comments.

Comments

0

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];

1 Comment

I upgraded my Php to the newest version and the parser error is gone. Thanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.