Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

syntax error, unexpected end of file

Description

The unexpected end of file happens when PHP has not finished parsing a file, and still expected a few more tokens to complete it.

Usually, this means that not enough code was provided, or also, that some code instruction were not completed as expected.

In the example here, the expression is completed with a semi-colon, or a closing PHP tag. Both would conclude the expression, and the script, but they are not available.

Example

<?php

$x = 1

Alternatives

  • Make sure all expression are completed.