小编Lan*_*box的帖子

需要帮助诊断:解析错误:语法错误,意外T_FUNCTION

我收到这个错误:

解析错误:语法错误,意外T_FUNCTION

在这段代码:

<?php
    $uniqueFtypes = $ftypes = $converter->GetConvertedFileTypes();
    array_walk(
        $uniqueFtypes, 
        function(&$ftype, $key) {
            $ftype = $ftype['fileExt'];
        }
    );
    $uniqueFtypes = array_values(array_unique($uniqueFtypes));
    foreach ($uniqueFtypes as $key => $uftype)
    {
        echo $uftype;
        echo ($uftype != end($uniqueFtypes)) ? (($key != count($uniqueFtypes)-2) ? ', ' : ', or ') : '';
    }
?>
Run Code Online (Sandbox Code Playgroud)

在这一行:

array_walk(
    $uniqueFtypes, 
    function(&$ftype, $key) {
        $ftype = $ftype['fileExt'];
    }
);
Run Code Online (Sandbox Code Playgroud)

PHP版本:5.2.17

它适用于localhost,我正在使用最新的UniServer.但当我把它移动到我的主机时,它会给出错误.

有帮助吗?:)

编辑:这是其他人我不确定它是否需要修复.

ini_set('max_execution_time',0);
ini_set('display_errors',0);

// Instantiate converter class
include 'VideoConverter.class.php';
$converter = new VideoConverter();

// On download …
Run Code Online (Sandbox Code Playgroud)

php

1
推荐指数
1
解决办法
453
查看次数

如何访问事件侦听器内的类函数

我在这里遇到一个小问题,我不想向单击事件添加事件侦听器。当点击发生时,函数会正常触发,但是当它应该调用另一个函数时,它会给出错误:

TypeError: this.addEvent is not a function
Run Code Online (Sandbox Code Playgroud)

代码:

class TEST {
    construct(){
        this.events = [];
    }
}

TEST.prototype.ready = function(callback) {
    if (document.readyState!='loading') callback();
    else if (document.addEventListener) document.addEventListener('DOMContentLoaded', callback);
    else document.attachEvent('onreadystatechange', function(){
        if (document.readyState=='complete') callback();
    });
}

TEST.prototype.addEvent = function (event) {
    this.events.push(event);
}

TEST.prototype.clickEvent = function (e) {
    var pos = {
        x: e.pageX,
        y: e.pageY
    };

    var event = {
        type: 'click',
        data: pos,
        timestamp: new Date()
    };

    this.addEvent(event);
}

TEST.prototype.init = function () {
    document.addEventListener('click', this.clickEvent);
} …
Run Code Online (Sandbox Code Playgroud)

javascript prototype addeventlistener

1
推荐指数
1
解决办法
1391
查看次数

标签 统计

addeventlistener ×1

javascript ×1

php ×1

prototype ×1