Syntax error PHP CompileError

PHP CompileError



Introduction

In PHP 7.3 onwards, CompileError exception has been added. This class inherits Error class. Some error conditions that previously resulted in fatal error, now throw a CompileError. This affects compilation errors that are likely to be thrown by token_get_all() function.

The token_get_all() function uses Zend lexical scanner to parse a given string into PHP language tokens.

Syntax

token_get_all ( string $source [, int $flags = 0 ] ) : array

Parameters

Sr.No Parameter & Description
1 source
PHP source to parse
2 flag
TOKEN_PARSE - Recognises the ability to use reserved words in specific contexts.

The function should be used in TOKEN_PARSE mode to be able to raise CompileError.

Updated on: 2020-09-21T11:30:17+05:30

251 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements