如何解决PHP echo gettext 从一个类
我对类有点陌生,并尝试从方法中返回一个数组和一个 gettext 字符串,因此我可以稍后验证该数组并回显该字符串。 由于我缺乏知识,我认为这更像是一个语法问题 - 但我无法弄清楚如何避免使用非法偏移字符串发出警告。简化的代码如下。希望有人能帮忙?
class.php
SQL> select *
2 from test
3 pivot
4 (max(COLVALUE)
5 FOR KEY IN ('height','length','width')
6 )
7 order by 1;
MSGID 'he 'le 'wi
---------- --- --- ---
15 18 19 20
16 21 22 23
17 24 25 26
SQL>
index.php
class test {
private $a = 1;
public function validate() {
if($this->a == 1) {
//return _("SUCCESS"); <-this works fine
//I would like to return array AND gettext message together
//something like this I tried:
return array('status'=>1,'message'=>_("SUCCESS"));
}
}
$test = new test();
解决方法
class.php
class test {
private $a = 1;
public function validate()
{
if($this->a == 1)
return array('status'=>1);
}
}
index.php
include('class.php');
$test = new test();
$message = $test->validate();
echo $message['status'];
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。