Error: The object of the class cannot be converted to a string if the server-side setting is ignored?

Source: Internet
Author: User
Tags call back pear php error
Catchable fatal error:object of class could not being converted to string in
Error: Object of class cannot be converted to string

It is said that the reason is because: php5 is not used = directly assign to the variable, = and =& are the same as the reference instead of copy so when the pair is turned off, $a reference value is gone


How to set up on the server side, so that php5 can pass the = variable directly, instead of converting the library string? So there's no such thing as a wrong hint.


Reply to discussion (solution)

Post the relevant 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);
}
}
}

Code no problem, in other servers can be normal operation, this server does not work, should be related to the server configuration, is not the php.ini in which to set up a bit?

If you change the database in the Int (12) to varchar (12), open the Web page there is no error warning, but the database can not be changed all int to varchar, not to mention the site program and database in other server space can be normal operation, so should be this server where there is a problem, please advise!! Thanks!!!

That could be your PEAR version problem.
Few people in the country with this thing, you go to the foreign site to ask

Find some information, but do not understand which one can ignore the error and let the page display properly?
Pear_error
Pear_error is a base class for PEAR Error objects, unlike PEAR, which in general, you can create instances of pear_error directly, creating the way: $error = new Pear_error ($message, $code, $mode, $ Options, $userinfo);

$message is your error message, $code is the error number of the error, and the following 3 parameters are closely related:
$mode: This is the wrong processing mode and can be the following constants:
Pear_error_return: Returns the Error object only (default)
Pear_error_print: This error message is printed in the build function, but the current program continues to run.
Pear_error_trigger: Use PHP trigger_error () to trigger an error, if you have set the error handling function, or if you set PHP error handling level to E_user_error, then the current program will be terminated.
Pear_error_die: Print error and exit, program terminated.
Pear_error_callback: A callback function or method is used to handle the current error and the program terminates.
$options: This parameter only works when $mode is Pear_error_trigger and pear_error_callback, and if it is Pear_error_trigger, $options must be e_user_ NOTICE, e_user_warning, or E_user_error, one of the 3 constants, is consistent with the value of Trigger_error in PHP. If $mode is Pear_error_callback, the $options can be a string, the function name to call back, or an array of 2 elements, one object variable, and one string (indicating the method to invoke).
$userinfo: To store additional user information, you can put the relevant debugging information here.

There are some commonly used methods in Pear_error, these methods are not described in PHP text block, here are listed:

int GetMode: Returns the current error-handling mode, integer.
String GetMessage: Returns the current complete error message, String.
Mixed getcallback: Returns the current callback information, possibly the callback function name, or an array of (objects, methods).
int GetCode: Returns the error code for the integer type.
String GetType: Returns the type of the error, which is the current class name, String.
String GetUserInfo: Returns the appended user information, string.
String Getdebuginfo: Same as the content.
String toString: Returns a detailed string description of the current object, including error-handling patterns, levels, error messages, error codes, related callback functions, and so on.

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.