dongmibeng5885 2019-08-02 14:34
浏览 160

请求帮助修复php脚本错误

i got this unexpected error after site builder set up. Since I'm not familiar with CSS or PHP scripts, I'm not able to see the error which should be on line 8 and line 19 (according to the 500 error code).

There was no closing line (?>) at the end of the script, which is now added by me. Can you plese help me to fix other errors? thank you in advance for your help

<?php
/**
 * @see       https://github.com/zendframework/zend-diactoros for the canonical source repository
 * @copyright Copyright (c) 2018 Zend Technologies USA Inc. (https://www.zend.com)
 * @license   https://github.com/zendframework/zend-diactoros/blob/master/LICENSE.md New BSD License
 */

declare(strict_types=1); // Error highlighted issue with this line.

namespace Zend\Diactoros;

/**
 * Create an uploaded file instance from an array of values.
 *
 * @param array $spec A single $_FILES entry.
 * @throws Exception\InvalidArgumentException if one or more of the tmp_name,
 *     size, or error keys are missing from $spec.
 */
function createUploadedFile(array $spec) : UploadedFile // Error highlighted issue with this line.
{
    if (! isset($spec['tmp_name'])
        || ! isset($spec['size'])
        || ! isset($spec['error'])
    ) {
        throw new Exception\InvalidArgumentException(sprintf(
            '$spec provided to %s MUST contain each of the keys "tmp_name",'
            . ' "size", and "error"; one or more were missing',
            __FUNCTION__
        ));
    }

    return new UploadedFile(
        $spec['tmp_name'],
        $spec['size'],
        $spec['error'],
        isset($spec['name']) ? $spec['name'] : null,
        isset($spec['type']) ? $spec['type'] : null
    );
}
?>
  • 写回答

1条回答

  • dq13733519262 2019-08-02 18:54
    关注

    Given the errors are about the only lines that consist of php7+ only code, the problem is likely an outdated version of php.

    There are two solutions: the better solution is to upgrade your php version to 7.2; ask your hosting provider if they're able to accommodate you in that regard.

    Your other option is probably faster: simply remove the php7 code. The problem is about these parts:

    declare(strict_types=1);
    

    And

    (...) : UploadedFile
    

    Both of these can be removed without consequence.

    In short: Remove line 8, and replace line 19 with:

    function createUploadedFile(array $spec)
    

    Edit:

    To do it really well, you might consider adding this:

     * @return UploadedFile
    

    Right between the lines with @param and @throws. It's the php5.x alternative for : UploadedFile.

    PS: The ?> thing is supposed to be missing. Having it still works in most cases, but taking it out again is the better way.

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题