Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用hsl着色和使用php代码的函数_Php_Html - Fatal编程技术网

使用hsl着色和使用php代码的函数

使用hsl着色和使用php代码的函数,php,html,Php,Html,我已经完成了这段代码,但是它不是我想要的工作方式。我正在给一根绳子上色。颜色由一个函数getcolor决定,该函数由一个名为raw transform的函数决定,该函数将原始分数转换为我的开关案例中1-9的分数。有人能帮忙吗$col由另一个函数赋值-为了参数起见,让我们将其定义为:$col=0 输出不包括所选核苷酸的着色。有人知道为什么吗?您没有分配getcolor$score的返回值;一个变量。我打赌它应该是$truecol=getcolor$score;调用colorSequence$seq

我已经完成了这段代码,但是它不是我想要的工作方式。我正在给一根绳子上色。颜色由一个函数getcolor决定,该函数由一个名为raw transform的函数决定,该函数将原始分数转换为我的开关案例中1-9的分数。有人能帮忙吗$col由另一个函数赋值-为了参数起见,让我们将其定义为:$col=0


输出不包括所选核苷酸的着色。有人知道为什么吗?

您没有分配getcolor$score的返回值;一个变量。我打赌它应该是$truecol=getcolor$score;调用colorSequence$seq,49,$truecol,1;之前

您尚未解释问题所在。请先尝试学习编程:getcolor不返回值;调用该函数时不传入第二个参数;等等–这是编程基础…通过将每个案例标记为变量$truecol,我没有返回它吗?不,通过返回值,您将返回它:函数getAbc{return$abc;}另请参见:
<?php

$raw= 650;
function rawtransform($raw) {
  $score = (int)($raw/50)-9;
}
    //==========================================================================
//            Function to decide which color system                         //
//==========================================================================   
function getcolor($score, $col)
{
switch ($score){
// to return the function best way is to declare the case outcome as a variable eg.$truecol
case 1: /*500-550(Raw Score)*/
    $truecol="<span style=\"color: hsl($col,100%,90%);\">";
    break;
case 2: //550-600
    $truecol="<span style=\"color: hsl($col,100%,80%);\">";
    break;
case 3: //600-650
    $truecol="<span style=\"color: hsl($col,100%,70%);\">";
    break;
case 4: //650-700
    $truecol="<span style=\"color: hsl($col,100%,60%);\">";
    break;
case 5: //700-750
    $truecol="<span style=\"color: hsl($col,100%,50%);\">";
    break;
case 6: //750-800
    $truecol="<span style=\"color: hsl($col,100%,40%);\">";
    break;
case 6: //800-850
    $truecol="<span style=\"color: hsl($col,100%,30%);\">";
    break;
case 7: //850-900;
    break;
case 8: //900-950
    $truecol="<span style=\"color: hsl($col,100%,20%);\">";
    break;
case 9: //950-1000
    $truecol="<span style=\"color: hsl($col,100%,10%);\">";
    break;
   }
}

   $query="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC";

$seq=chunk_split($query,50,"<br />");
getcolor($score);
function colorSequence ($seq,$position,$truecol,$TFBSlength){
    $nucleotides = str_split($seq);
    foreach ($nucleotides as $index => $nucl){
        if ($index == $position){
            echo $truecol;
        }
        if ($index == $position + $TFBSlength){
            echo "</span>";
        }

        echo $nucl;
    }
    echo "\n";
}
colorSequence($seq,49,$truecol,1);
?>