APC __PHP_Incomplete_Class_Name

I am studying the use of APC in PHP. I created this script to check it out:

<?php

require 'Person.php';

if (!$p = apc_fetch('p')) {
    $p = new Person('larry');
    apc_store('p', $p);
}

echo $p->getName();

where Person.php:

<?php

class Person
{
    private $_name;

    public function __construct($_name)
    {
        $this->_name = $_name;
    }

    /**
     * @param mixed $name
     */
    public function setName($_name)
    {
        $this->_name = $_name;
    }

    /**
     * @return mixed
     */
    public function getName()
    {
        return $this->_name;
    }
}

It works fine, but the stored value in apc:

__PHP_Incomplete_Class::__set_state(array(
'__PHP_Incomplete_Class_Name' => 'Person',
'_name' => 'larry',
))

this is normal? or something is wrong with '__PHP_Incomplete_Class_Name'

thank

+3
source share
2 answers

While I do not know APC, it is __PHP_Incomplete_Class_Nameusually caused by an attempt to access an object when you do not have a definition for the class

You often see this when called session_startbefore you include or require your class structures, or non-ethericize something when you do not have its definition.

, ( ) , , APC, , .

+2

... , , , , php , . "Person.php"; , , , . , .

+1

All Articles