if like me, you're working inside a framework where you can't require the file with the class definition before session_start is called, I found the following workaround:
$whatever = unserialize(serialize($_SESSION['whatevever']));
dirty hackish, but works.
main
(No version information available, might be only in CVS)
main — Fausse documentation pour main()
Description
Il n'y a pas de fonction appelée main(), hormis dans les sources PHP. En PHP 4.3.0, un nouveau type de gestion d'erreur a été introduit dans les sources de PHP : php_error_docref. Une des fonctionnalité était de fournir un lien vers la page de manuel de PHP lorsque les directives html_errors (par défaut) et docref_root (par défaut jusqu'en PHP 4.3.2) sont activées.
Certains messages d'erreur faisaient référence à une page de manuel pour la fonction main() alors que cette page n'existe pas. Ajoutez une note utilisateur, en anglais, où vous mentionnez la fonction PHP vous ayant conduite sur cette page. Cette erreur sera corrigée et documentée.
| Nom de la fonction | Ne pointe plus sur cette page depuis la version |
|---|---|
| include() | 5.1.0 |
| include_once() | 5.1.0 |
| require() | 5.1.0 |
| require_once() | 5.1.0 |
main
04-Jul-2008 04:29
26-Jun-2008 04:32
In addition to Maurice's comments:
the "The script tried to execute a method or access a property of an incomplete object" message can appear also if you store your objects in session, and rename class during that session.
For example, you have class "class_name", and there is a class variable "$class_var = new class_name".
If you decide to rename your class, you would have "$class_var = new class_new_name".
This re-naming will result in abovementioned error message if you store $class_var in session.
Solution: clean-up session variable, then error disappears.
21-Feb-2008 07:10
To put it simple: main() refers to anything running in the current PHP script file that isn't part of any function.
27-Nov-2007 10:31
Additional note about what Maurice said: you can also use an __autoload function which will get called as the session/var is unserialized.
This will allow you to not preload all possible classes before loading a session, and let them be loaded dynamically. Check http://php.net/oop5.autoload for more details about this magic function.
01-May-2006 11:12
Notice: main() [function.main]: The script tried to execute a method or access a property of an incomplete object. Please ensure that the class definition "<classname>" of the object you are trying to operate on was loaded _before_ unserialize() gets called or provide a __autoload() function to load the class definition in <filename> on line <line>
You get this error if you have and object in your $_SESSION array and you call session_start() before you have loaded your included classes.
