首页 > 解决方案 > 无法在第 9 行的 Colorido.class.php 中重新声明之前在 Colorido.class.php:9 中声明的 wfColoridoRender

问题描述

执行这部分代码时出现以下错误:

无法在 /data/web/a1/eb/ 中重新声明 wfColoridoRender()(之前在 /data/web/a1/eb/4e/.../htdocs/wiki/extensions/Colorido/Colorido.class.php:9 中声明)第 9 行的 4e/.../htdocs/wiki/extensions/Colorido/Colorido.class.php

这段代码有什么问题?我不明白出了什么问题

代码完成:

<?php
 
$wgHooks['ParserFirstCallInit'][] = 'onParserFirstCallInit';

function onParserFirstCallInit( Parser $parser ) {
    $parser->setHook( 'colorido', 'wfColoridoRender' );
}

include_once wfColoridoRender( $input, $argv, $parser ) { 
 
    // Character styles
    $input = utf8_decode($input);
    $output = ""; // To stop the "Undefined Variable" errors in the webserver logfile
 
    for ($i = 0; $i < strlen($input); $i++)
      {
    $s = rand(0, 9) * 8 + 150;
    $w = rand(5, 9) * 100;
    $r = rand(20, 230);
    $g = rand(20, 230);
    $b = rand(20, 230);
 
    $output .= 
      '<span style="font-size: ' . strval($s) . '%; font-weight:' 
      . strval($w) . ';color: #' . dechex($r) . dechex($g) . dechex($b) 
      . ';">';
 
    $output .= $input[$i];
    $output .= '</span>';
      }
      
    return utf8_encode($output);
};

标签: phpmediawiki

解决方案


推荐阅读