php 5.1.6 魔术__toString 方法 [英] php 5.1.6 magic __toString method

查看:36
本文介绍了php 5.1.6 魔术__toString 方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 codeigniter 我试图使用 这个 插件,它需要我在我的模型中实现一个 toString 方法.我的 toString 方法很简单

In codeigniter Im trying to use this plugin which requires I implement a toString method in my models. My toString method simply does

public function __toString()
{
    return (string)$this->name;
}

在我使用 php 5.3 的本地机器上一切正常,但在使用 php 5.1.6 的生产服务器上,它显示对象 id#48",该对象的 name 属性的值应该出现.....我发现了一些关于 这里有问题,但我还是不明白......我该如何解决这个问题?

On my local machine with php 5.3 everything works just fine but on the production server with php 5.1.6 it shows "Object id#48" where the value of the name property of that object should appear..... I found something about the problem here but I still dont understand... How can I fix this?

推荐答案

升级 PHP

我正在处理同样的问题,我怀疑您最好的选择是将生产服务器上的 php 升级到 >= 5.2.0

I'm dealing with the same problem, I suspect your best option will be to upgrade php on the production server to >= 5.2.0

在未来(我目前正在艰难地学习这一点),尝试在您将部署到的同一版本上进行开发.

In the future (I'm currently learning this the hard way), try to develop on the same version you will deploy to.

这篇关于php 5.1.6 魔术__toString 方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆