Fatal error: Call to private MyObject::__construct() from invalid context
2011-07-07 15:02
573 查看
问题: When creating a new object in PHP, I get the following error message:
I just create the new object and do not try to call the constructor explicitly. Does anyone know what's going on? 解释:Your
Fatal error: Call to private MyObject::__construct() from invalid context
I just create the new object and do not try to call the constructor explicitly. Does anyone know what's going on? 解释:Your
MyObjectclass has a protected or private constructor, which means that the class cannot be instantiated.
__construct()functions are always called when an object is instantiated, so trying to do something like
$x = new MyObject()will cause a fatal error with a private construction function. (If you do not specifically declare a
__construct()function, the parent constructor will be called).Private constructors are often used in Singleton classes to prevent direct instantiation of an object. If it's not a class that you built, it might have a
getInstance()function available (or something similar) to return an instance of itself.
相关文章推荐
- 又一个错误" Fatal error: Call to undefined function myabp_print_screenshot_all() "
- magento后台 Fatal error: Call to a member function getId() on a non-object in错误
- magento 第四章 出现 "Fatal error:Call to a member function load() on a non-object in \Abstract.php" 问题
- Fatal error: Call to a member function table() on a non-object in
- dedecms中自定义模型遇到错误Fatal error: Call to a member function GetInnerText() on a non-object
- symfony 错误 Fatal error: Call to undefined function object_admin_input_upload_tag()
- Fatal error: Call to a member function insert() on a non-object in /opt/lamp...
- Wordpress PHP Fatal error: Call to a member function get() on a non-object 解决方法
- Error generating shape from text: Invalid text used to construct geometry (-1)
- Fatal error: Call to a member function fetch_array() on a non-object in E:\wamp\www\shop\index.php
- Fatal error: Call to** function read() on a non-object inC:*\*\select_templets.php on line *的解决方法
- malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
- Fatal error: Call to a member function setAttribute() on a non-object in Magento
- malloc: *** error for object 0x6080000bd200: Invalid pointer dequeued from free list *** set a breakpoint in malloc_error_break to debug
- Fatal error: Call to a member function fetch_row() on a non-object in C:\wamp\www\baicaotang\admin\m
- Fatal error: Call to a member function read() on a non-object in D:\wamp\www\include\dialog\select_i
- Magento Fatal Error: Call to member function getSku() on a non-object
- "malloc: * error for object 0x17415d0c0: Invalid pointer dequeued from free list * set a breakpoint in malloc_error_break to debug";
- Fatal error: Call to a member function get() on a non-object
- Fatal error: Call to a member function fetch_array() on a non-object问题的解决办法