PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

memory_get_peak_usage> <ini_set
Last updated: Fri, 18 Jul 2008

view this page in

main

(No version information available, might be only in CVS)

main — Riferimento a main()

Descrizione

Non esiste una funzione main() tranne che nel sorgente PHP. Dal PHP 4.3.0 è stata introdotta nel sorgente una nuova tipologia di errore gestibile (php_error_docref). Una caratteristica di questa è quella di fornire il link alla pagina del manuale nel messaggio di errore nel caso in cui la direttiva html_errors (on per default) e docref_root (on per default dal PHP 4.3.2) siano impostate.

Qualche volta gli errori fanno riferimento alla pagina del manuale per la funzione main() ed è per questo che esiste questa pagina. Si prega di aggiungere nei commenti sottostanti quale funzione PHP ha cusato l'errore che punta a main(), e questo sarà prontamente corretto e documentato.

Errori noti che punatno a main()
Nome della funzione Non punta più qui da
include() 4.3.2
include_once() 4.3.2
require() 4.3.2
require_once() 4.3.2

Vedere anche html_errors e display_errors.



memory_get_peak_usage> <ini_set
Last updated: Fri, 18 Jul 2008
 
add a note add a note User Contributed Notes
main
penny at mjollnir dot org
04-Jul-2008 01:29
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.
Anonymous
26-Jun-2008 01: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.
deryckchan [ATT] gmail D0T C0M
21-Feb-2008 04:10
To put it simple: main() refers to anything running in the current PHP script file that isn't part of any function.
MagicalTux at kinoko dot fr
28-Nov-2007 07: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.
Maurice
01-May-2006 08: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.

memory_get_peak_usage> <ini_set
Last updated: Fri, 18 Jul 2008
 
 
show source | credits | stats | sitemap | contact | advertising | mirror sites