Parse error: syntax error, unexpected ':', expecting ';' or '{'

Hi everyone,
I have installed wordpress on my localhost(wamp). during the installation process, everything was good, however when I go to the first page I see this error:
Parse error: syntax error, unexpected ‘:’, expecting ‘;’ or ‘{’ in D:\wamp64\www\woocommerce\wp-content\plugins\tutor\classes\Utils.php on line 2853
I tried to find the problem, and changed some actions to solve it. but it does not work. Here is the code:

public function get_students_by_instructor( int $instructor_id, int $offset, int $limit, $search_filter = '', $course_id = '', $date_filter = '', $order_by = '', $order = '' ): array {
		global $wpdb;

Does anyone have idea?
Thanks in advance

You are missing the closing ) followed by a {

1 Like

The : array syntax, after the closing ), is php’s return value type hinting. It’s a syntax error because your php version is not high enough.

1 Like

Thanks, so what is the problem?
The only way is that I have to upgrade my WAMP?

I didn’t find any direct information on what php version you need for that syntax to work (it would take searching through the php migration indexes in the documentation or though the change log.)

The WP installation source you found should list the minimum php version that’s required.

You should be using at least the highest available php 7 version.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service