【问题标题】:I get error when i execute amfphp file执行 amfphp 文件时出现错误
【发布时间】:2018-04-10 17:25:36
【问题描述】:

我的站点中有一个带有 Flash 的页面,但我遇到了问题。 当我尝试直接执行文件 site.com/amfphp/gateway.php 时,我收到此错误:

致命错误:带有消息的未捕获异常“VerboseException” '不应调用非静态方法 CharsetHandler::setMethod() 静态地,假设 $this 来自不兼容的上下文' in ....

function service() {

//Set the parameters for the charset handler
CharsetHandler::setMethod($this->_charsetMethod); // the problem point here
CharsetHandler::setPhpCharset($this->_charsetPhp);
CharsetHandler::setSqlCharset($this->_charsetSql);

//Attempt to call charset handler to catch any uninstalled extensions
$ch = new CharsetHandler('flashtophp');
$ch->transliterate('?');

$ch2 = new CharsetHandler('sqltophp');
$ch2->transliterate('?');

我该如何解决这个问题?

【问题讨论】:

  • 也许尝试在每个对象上调用该方法? $ch->setMethod($this->_charsetMethod);
  • 我会调用它,但是我应该放什么参数$ch = new ChasetHandler(' HERE ');

标签: php flash amfphp


【解决方案1】:

显然 CharsetHandler 类的 setMethod 函数不是静态的。这意味着除非您有该类的实例,否则您不能调用它。 Alexander 建议对两个实例中的每一个调用 setMethod 是适当的。您的代码应为:

function service() {

    //Set the parameters for the charset handler
    CharsetHandler::setPhpCharset($this->_charsetPhp);
    CharsetHandler::setSqlCharset($this->_charsetSql);

    //Attempt to call charset handler to catch any uninstalled extensions
    $ch = new CharsetHandler('flashtophp');
    $ch->setMethod($this->_charsetMethod);
    $ch->transliterate('?');

    $ch2 = new CharsetHandler('sqltophp');
    $ch2->setMethod($this->_charsetMethod);
    $ch2->transliterate('?');

如果您静态调用的其他两个方法确实是静态的,这应该可以工作。

【讨论】:

    猜你喜欢
    • 2019-04-29
    • 1970-01-01
    • 2015-10-26
    • 1970-01-01
    • 2021-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-03-09
    相关资源
    最近更新 更多