-1

Parse error: syntax error, unexpected 'const' (T_CONST), expecting variable (T_VARIABLE) in C:\PHP\OSPANEL\OSPanel\domains\newyearshop.ua\classes\PdoConnect.php on line 5

PdoConnect.php:

<?php

class PdoConnect {

    private const HOST = 'localhost';
    private const DB = 'newyear';
    private const USER = 'newyear';
    private const PASS = 'newyear';
    private const CHARSET = 'utf8';

    protected $DSN;
    protected $OPD;
    public $PDO;

    private function __construct() {
        
        $this->DSN = "mysql:host=" . self::HOST . ";dbname=" . self::DB . ";charset=" . self::CHARSET;

        $this->OPD = array(
            PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
            PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
            PDO::ATTR_EMULATE_PREPARES => false,
        );

        $this->PDO = new PDO($this->DSN, self::USER, self::PASS, $this->OPD);
    }

Dharman
  • 30,962
  • 25
  • 85
  • 135
bodis_
  • 11
  • 2

1 Answers1

1

Private constants were introduced in PHP 7.1, but it appears you are using an older version.

Instead of

    private const HOST = 'localhost';

(and so on) put

    const HOST = 'localhost';
Dharman
  • 30,962
  • 25
  • 85
  • 135
Rob Eyre
  • 717
  • 7