2017-01-02 31 views
1

我得到在我的服務器錯誤訪問私有財產,PHP無法裏面

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

當我打電話

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

我收到錯誤

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

此錯誤保顯示事件我將_encryptionkey更改爲受保護的,但如果我更改爲公共,錯誤消失。

我的服務器上運行PHP 7.1.0版本使用爾康版本3.0.3

+0

它的工作: - https://eval.in/707425 –

+0

http://stackoverflow.com/questions/4361553/what-is-the-difference-between-public-private-and-protected閱讀此 –

+1

我想知道它的'phalcon'具體的 –

回答

0

爾康不支持PHP 7.1因此它可能是錯誤與爾康編譯爲PHP 7.1

使用PHP 7.0你將不會有這個問題。