Strange error on server

Hi!

A client just deployed a site I developed with K3 to a shared hoster. During the development I used Fortrabbit where everything worked as intended. On the shared Hoster (php 7.2.7) i get a really strange error:
Parse error : syntax error, unexpected T_OBJECT_OPERATOR, expecting ‘,’ or ‘;’ in /index.php on line 5

htaccess file is set up, even tried to close the php tags in this file (while i know this is not necessary)

any ideas? thanks in advance

Is it really 7.2.7? I’m not sure which exact version added support for using instantiated objects immediately without saving them into variable first, but I’m pretty sure 7.2.7 should support that—I would look into PHP settings of the hoster.

// Instead of this
$obj = new Kirby
$obj->method()

// You can do this
(new Kirby)->method()

That’s what Kirby does in the public index.php file, so your PHP failing suggests that your client is, in fact, running a different version.

1 Like

It’s not only not necessary, you shouldn’t close PHP tags in PHP-only files.


The requirement for Kirby is PHP 7.1+, not PHP 7.2.

Since Kirby uses system checks and renders a fatal PHP view once it encounters a PHP version below that, I wonder if this is really a PHP version issue.

Is your index.php the original Kirby index file, or have you made any changes (custom folder setup or something like that?)

1 Like

Thanks to both of you for your reply. I could solve it, but this is a different kind of story, let’s summarize it with this: the client messed up the folders linked to his domain totally and even forgot to upload some folders (for reasons i could not find out) but insisted on the fact that I am wrong…

(And yeah, it’s been php5, the client put my info-file into a wrong directory. complicated as they didn’t grant me access to their server, whatever).

Thanks again (as always) and
@texnixe, good to know, i should not close the tags, thanks for clarifying. really appreciated.

1 Like