为什么我的PHP echo()命令没有按预期工作?

时间:2014-08-22 05:54:42

标签: php html

我调用一个我知道子字符串存在的函数,并且echo命令将不会按照我想要的方式工作。

似乎总是回应字符串说它不存在。对于此示例,我们可以将其设置为键。

$KEY = "R1*PFD1V1FE1VS1BF1SP1NL2OW1TP1MSD1NR1";

function displayNL( $KEY ) {

    switch ( true ) {
        case ( is_numeric( strpos($KEY, 'NL1') ) ) :
            echo "Masthead Light: May replace with Electric Torch or Lantern    Sidelights: May replace with Electric Torch or Lantern  Sternlight: May replace with Electric Torch or Lantern  Other Lights: -   Dayshapes: - ";
            break;
        case ( is_numeric ( strpos($KEY, 'NL2') ) ) :
            echo "Masthead Light: May replace with Electric Torch or Lantern    Sidelights: May replace with Electric Torch or Lantern   Sternlight: May replace with Electric Torch or Lantern Other Lights: All Around Red over All Around Green on Masthead (OPTIONAL)   Dayshapes: -" ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL3') ) ) :
            echo "Masthead Light: May replace with Electric Torch or Lantern    Sidelights: May replace with Electric Torch or Lantern  Sternlight: May replace with Electric Torch or Lantern  Other Lights: All Around Red over All Around Green on Masthead (OPTIONAL)   Dayshapes: When under power and in International Waters, Cone with Apex Down" ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL4') ) ) :
            echo "Masthead Light: May replace with All Around White Light   Sidelights: May forego if impracticle to mount  Sternlight: May replace with Other Lights: All Around White Light - Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL5') ) ) :
            echo "Masthead Light: May replace with All Around White Light   Sidelights: May have Sidelights Combined in Single Lantern on Centerline    Sternlight: May replace with Other Lights: All Around White Light   -   Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL6') ) ) :
            echo "Masthead Light: Masthead Light Not Required   Sidelights: May have Single Lantern with Sidelights and Sternlights on Mast Sternlight: May have Single Lantern with Sidelights and Sternlights on Mast Other Lights: All Around Red over All Around Green on Masthead (OPTIONAL)   Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL7') ) ) :
            echo "Masthead Light: Masthead Light Not Required   Sidelights: May have Single Lantern with Sidelights and Sternlights on Mast Sternlight: May have Single Lantern with Sidelights and Sternlights on Mast Other Lights: All Around Red over All Around Green on Masthead (OPTIONAL)   Dayshapes: When under power and in International Waters, Cone with Apex Down " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL8') ) ) :
            echo "Masthead Light: Required  Sidelights: May have Sidelights Combined in Single Lantern on Centerline    Sternlight: Required    Other Lights: - Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL9') ) ) :
            echo "Masthead Light: Required  Sidelights: Required    Sternlight: Required    Other Lights: - Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL1*0') ) ) :
            echo "Masthead Light: Required  Sidelights: Required    Sternlight: Required    Other Lights: All Around Red over All Around Green on Masthead  Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL1*1') ) ) :
            echo "Masthead Light: Required  Sidelights: Required    Sternlight: Required    Other Lights: All Around Red over All Around Green on Masthead  Dayshapes: When under power, Cone with Apex Down " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL1*2') ) ) :
            echo "Masthead Light: Required, 2   Sidelights: Required    Sternlight: Required    Other Lights: - Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL1*3') ) ) :
            echo "Masthead Light: Required, 2   Sidelights: Required    Sternlight: Required    Other Lights: All Around Red over All Around Green on Masthead  Dayshapes: - " ;
            break;
        case ( is_numeric ( strpos($KEY, 'NL1*4') ) ) :
            echo "Masthead Light: Required, 2   Sidelights: Required    Sternlight: Required    Other Lights: All Around Red over All Around Green on Masthead  Dayshapes: When under power, Cone with Apex Down " ;
            break;
        default:
            echo "Make sure you selected somthing OR This Combination Does Not Exists ";

    }
}


displayNL( $KEY ) ;

1 个答案:

答案 0 :(得分:0)

这对我有用......我认为这个错误是另一回事。如果它没有返回任何内容,请尝试使用die来调试代码(' break');在此代码块之前。这是您可以用来识别错误的最简单的调试方法。

如果骰子不起作用,则代码块上方会出现错误。