Fatal error: Call to private MyObject::__construct() from invalid context
来源:互联网 发布:xd软件下载 编辑:程序博客网 时间:2024/05/16 05:32
When creating a new object in PHP, I get the following error message: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 MyObject
class 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 private MyObject::__construct() from invalid context
- Error armlink L6238 Startup.o(Start) contains invalid call from '~PRES8' function to 'REQ8' functio
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function curl_init()
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function
- Fatal error: Call to undefined function randstr()
- Fatal error: Call to undefined function openssl_pkey_get_private()
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function mcrypt_get_block_size()
- Fatal error: Call to undefined function cal_days_in_month()
- Fatal error: Call to undefined function file_iterator_autoload()
- Fatal error: Call to undefined function imagettftext()
- Fatal error: Call to undefined function imagettftext()
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function mb_strlen()
- Fatal error: Call to undefined function mysql_connect()
- Fatal error: Call to undefined function mb_detect_encoding()
- Android OpenGL教程-第一课
- C++基础之字符数组和字符串
- Android2.1消息应用(Messaging)源码学习笔记
- iphone4 UI全用代码实现在
- 续:队列的应用 之 M/D/1队列
- Fatal error: Call to private MyObject::__construct() from invalid context
- Tomcat中支持shtml
- ie6,ie7,ie8和firefox下兼容的图片上传预览
- IT行业的猪头小队长不好当
- U-Boot移植
- 什么是 haslayout
- PHP批量修改文件名小工具
- oracle索引的认识
- 09秋数据库课程设计_小结_1