Error: The class object cannot be converted to a string. if you set ignore on the server side? Catchable fatal error: Object of class cocould not be converted to string in
Error: The class object cannot be converted to a string.
It is said that this is because: php5 cannot use = to directly assign the object value to the variable, = and = & are all the same as the reference of the object rather than the copy object. so when the object is closed, the value referenced by $ a is gone.
So how can I set it on the server so that php5 can directly pass the = variable without converting the library string? In this way, there will be no error prompt
Reply to discussion (solution)
Post related code!
Function DB_Error ($ code = DB_ERROR,
$ Mode = PEAR_ERROR_RETURN,
$ Level = E_USER_NOTICE,
$ Debuginfo = null ){
If (is_int ($ code )){
$ This-> PEAR_Error ("DB Error:". DB: errorMessage ($ code), $ code, $ mode, $ level, $ debuginfo );
} Else {
$ This-> PEAR_Error ("DB Error: $ code", 0, $ mode, $ level, $ debuginfo );
}
}
}
The code is okay. it can run normally on other servers. This server won't work. it should be related to the server configuration. Is there any item in php. ini that should be set?
If you change int (12) in the database to varchar (12), there will be no error warning when you open the webpage, but you cannot change all the int values in the database to varchar, besides, website programs and databases can run normally in other server spaces, so it should be a problem with this server. please advise !! Thank you !!!
Maybe it's your PEAR version.
This is rarely used in China. you can ask on a foreign website.
Find some information, but do not understand which one can ignore the error and make the webpage display normally?
PEAR_Error
PEAR_Error is a base class of the PEAR error object. Unlike PEAR, you can directly create a PEAR_Error instance By: $ error = new PEAR_Error ($ message, $ code, $ mode, $ options, $ userinfo );
$ Message is your error message, $ code is the error number of the error, and the last three parameters are closely related:
$ Mode: the processing mode of this error. the following constants can be used:
PEAR_ERROR_RETURN: returns only the error object (default)
PEAR_ERROR_PRINT: this error message is printed in the build function, but the current program continues to run.
PEAR_ERROR_TRIGGER: trigger an error using PHP's trigger_error (). If you have set the error processing function or set the PHP error processing level to E_USER_ERROR, the current program will be terminated.
PEAR_ERROR_DIE: print the error and exit. The program is terminated.
PEAR_ERROR_CALLBACK: Use a callback function or method to handle the current error and terminate the program.
$ Options: this parameter takes effect only when $ mode is PEAR_ERROR_TRIGGER and PEAR_ERROR_CALLBACK. for PEAR_ERROR_TRIGGER, $ options must be E_USER_NOTICE, E_USER_WARNING, or E_USER_ERROR, the value is the same as that of trigger_error in PHP. If $ mode is PEAR_ERROR_CALLBACK, $ options can be a string with the name of the function to be called back, or an array of 2 elements, which is an object variable, and a string (indicating the method to be called ).
$ Userinfo: stores additional user information. you can put the relevant debugging information here.
PEAR_Error has some common methods. these methods are not described in the PHP document and are listed here:
Int getMode: returns the current error processing mode, an integer.
String getMessage: returns the current complete error message, a string.
Mixed getCallback: returns the current callback information, which may be the name of the callback function or an array (object, method.
Int getCode: return the error code of the integer type.
String getType: the type of the returned error, that is, the current class name, string.
String getUserInfo: returns the additional user information, a string.
String getDebugInfo: the content is the same as above.
String toString: returns the detailed string description of the current object, including the error processing mode, level, error information, error code, and related callback functions.