简体   繁体   中英

PHP Cannot access private property inside class

I am getting an error in my server,

<?php
class Encryption{
    private $_encryptionkey;
    public function setEncryption($key){
        $this->_encryptionkey = $key;
    }
}

when I call

$enc = new Encryption();
$enc->setEncryption("abcd123");

I am getting error

PHP Fatal error:  Uncaught Error: Cannot access private property Encryption::$_encryptionkey

This error keep show event i change _encryptionkey to protected, but error gone if i change to public.

My Server running PHP Version 7.1.0 using phalcon version 3.0.3

Phalcon doesn't support PHP 7.1 so it's probably bug with Phalcon compilation for PHP 7.1

With PHP 7.0 you will don't have this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM