GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Downloads
  • Documentation
  • Get Involved
  • Help
  • Getting Started
  • Introduction
  • A simple tutorial
  • Language Reference
  • Basic syntax
  • Types
  • Variables
  • Constants
  • Expressions
  • Operators

This view

  • Original page
  • New address

GeezerVison is showing www.php.net — PHP: ParseError - Manual

PHP 8.6.0 RC5 available for testing
    TypeError »
    « CompileError
    • Preface
    • Language Reference
    • Predefined Exceptions

    ParseError

    (PHP 7, PHP 8)

    Introduction

    ParseError is thrown when an error occurs while parsing PHP code, such as when eval() is called.

    Note:

    ParseError extends CompileError as of PHP 7.3.0. Formerly, it extended Error.

    Class synopsis

    class ParseError extends CompileError {
    /* Inherited properties */
    protected string $message = "";
    private string $string = "";
    protected int $code;
    protected string $file = "";
    protected int $line;
    private array $trace = [];
    private ?Throwable $previous = null;
    /* Inherited methods */
    public function Error::__construct(string $message = "", int $code = 0, ?Throwable $previous = null)
    final public function Error::getMessage(): string
    final public function Error::getPrevious(): ?Throwable
    final public function Error::getCode(): int
    final public function Error::getFile(): string
    final public function Error::getLine(): int
    final public function Error::getTrace(): array
    final public function Error::getTraceAsString(): string
    public function Error::__toString(): string
    private function Error::__clone(): void
    }

    Found A Problem?

    Learn How To Improve This Page • Submit a Pull Request • Report a Bug
    +add a note

    User Contributed Notes 2 notes

    up
    down
    0
    andrian dot test dot job at gmail dot com ¶
    6 years ago
    <?php
    /*
    * The function eval() evaluate his argument as an instruction PHP
    * Then the argument must respect the standar of PHP codage
    * In this example the semicolon are missign
    */
    
    try{
    
        eval("echo 'toto' echo 'tata'");
    
    }catch(ParseError $p){
    
        echo $p->getMessage();
    }
    
    /*
    * If you run this code the result is different of the result of above code
    * PHP will output the standar parse Error: syntax error, ....
    *
    
    eval("echo 'toto' echo 'tata'");
    
    */
    up
    down
    -2
    SixPigPigWikiSix ¶
    3 years ago
    The priority of Parse Error should be higher than that of Fatal Error,Parse Error, which has the highest priority among all PHP exceptions. See the following example:
    <?php
    error_reporting(E_ALL);
    test()
    //System output a parse error
    ?>
    <?php
    error_reporting(E_WARNING);
    test()
    //System output a parse error
    ?>
    <?php
    error_reporting(E_ERROR);
    test()
    //System output a parse error
    ?>
    <?php
    error_reporting(E_PARSE);
    test()
    //System output a parse error
    ?>
    +add a note
    • Predefined Exceptions
      • Exception
      • ErrorException
      • ClosedGeneratorException
      • Error
      • ArgumentCountError
      • ArithmeticError
      • AssertionError
      • DivisionByZeroError
      • CompileError
      • ParseError
      • TypeError
      • ValueError
      • UnhandledMatchError
      • FiberError
      • RequestParseBodyException
    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.