出错:类的对象不能被转换为字符串,如果在服务器端设置忽略?
Catchable fatal error: Object of class could not be converted to string in
出错:类的对象不能被转换为字符串
据说造成这个原因是因为:php5 中是不能用 = 直接把对像赋值给变量的, = 和 =& 都是一样都是对像的reference而不是copy所以当对像关了, $a 所参考的值也没了
那怎么在服务器端设置一下,让php5能直接传递 = 变量,而不用转换库字符串?这样就不会有那个出错提示
回复讨论(解决方案)
贴出相关代码!
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);
}
}
}
代码没问题,在其它服务器上都能正常运行,就这台服务器不行,应该与服务器配置有关,是不是php.ini中有哪项要设置一下?
如果将数据库中int(12)改成varchar(12),打开网页就没有出错警告,但总不能把数据库中所有int都改成varchar吧,何况网站程序和数据库在其他服务器空间都能正常运行,所以应该是这台服务器哪里有问题,请指教!!谢!!!
那可能是你的 PEAR 版本问题吧
国内很少有人用这个玩意的,你到国外的网站去问问
查到一些资料,但不明白哪一项可以忽略错误后让网页正常显示?
PEAR_Error
PEAR_Error是PEAR的错误对象的一个基类,和PEAR不同,一般来说,你可以直接创建PEAR_Error的实例,创建方式: $error = new PEAR_Error($message, $code, $mode, $options, $userinfo);
$message是你的错误信息,$code是该错误的错误号,后3个参数是紧密联系的:
$mode:是这个错误的处理模式,可以下列常量:
PEAR_ERROR_RETURN:仅仅返回该错误对象(缺省方式)
PEAR_ERROR_PRINT:在构建函数中打印这个错误信息,但是当前程序会继续运行。
PEAR_ERROR_TRIGGER:使用PHP的trigger_error() 触发一个错误,如果你已经设置了错误处理函数,或者你把PHP的错误处理级别设置为E_USER_ERROR,那么当前程序将会被终止。
PEAR_ERROR_DIE:打印错误并退出,程序终止。
PEAR_ERROR_CALLBACK:使用一个回调函数或者方法来处理当前错误,程序终止。
$options:这个参数只有在$mode是PEAR_ERROR_TRIGGER和PEAR_ERROR_CALLBACK的时候才起作用,如果是PEAR_ERROR_TRIGGER,$options必须是E_USER_NOTICE, E_USER_WARNING 或 E_USER_ERROR这3个常量的一个,同PHP中trigger_error的值一致。如果$mode是PEAR_ERROR_CALLBACK,$options可以是一个字符串,内容是要回调的函数名,也可以是一个2元素的数组,分别是一个对象变量,和一个字符串(标明要调用的方法)。
$userinfo:存放附加的用户信息,你可以把相关的调试信息放在这里。
PEAR_Error中有一些常用的方法,这些方法在PHP文挡没有描述,这里一一列出:
int getMode:返回当前的错误处理模式,整型。
string getMessage:返回当前完整的错误信息,字符串。
mixed getCallback:返回当前的回调信息,可能是所回调的函数名,或者是(对象,方法)的数组。
int getCode:返回整型的错误代码。
string getType:返回错误的类型,也就是当前的类名,字符串。
string getUserInfo:返回附加的用户信息,字符串。
string getDebugInfo:内容同上。
string toString:返回当前对象的详细字符串描述,内容包括错误处理的模式,级别,错误信息,错误代码,相关回调函数等等。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Long URLs, often cluttered with keywords and tracking parameters, can deter visitors. A URL shortening script offers a solution, creating concise links ideal for social media and other platforms. These scripts are valuable for individual websites a

Following its high-profile acquisition by Facebook in 2012, Instagram adopted two sets of APIs for third-party use. These are the Instagram Graph API and the Instagram Basic Display API.As a developer building an app that requires information from a

Laravel simplifies handling temporary session data using its intuitive flash methods. This is perfect for displaying brief messages, alerts, or notifications within your application. Data persists only for the subsequent request by default: $request-

This is the second and final part of the series on building a React application with a Laravel back-end. In the first part of the series, we created a RESTful API using Laravel for a basic product-listing application. In this tutorial, we will be dev

Laravel provides concise HTTP response simulation syntax, simplifying HTTP interaction testing. This approach significantly reduces code redundancy while making your test simulation more intuitive. The basic implementation provides a variety of response type shortcuts: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

The PHP Client URL (cURL) extension is a powerful tool for developers, enabling seamless interaction with remote servers and REST APIs. By leveraging libcurl, a well-respected multi-protocol file transfer library, PHP cURL facilitates efficient execution of various network protocols, including HTTP, HTTPS, and FTP. This extension offers granular control over HTTP requests, supports multiple concurrent operations, and provides built-in security features.

Do you want to provide real-time, instant solutions to your customers' most pressing problems? Live chat lets you have real-time conversations with customers and resolve their problems instantly. It allows you to provide faster service to your custom

The 2025 PHP Landscape Survey investigates current PHP development trends. It explores framework usage, deployment methods, and challenges, aiming to provide insights for developers and businesses. The survey anticipates growth in modern PHP versio
