PHP根据参数更改目录(来自url的$ GET)

I try to run project and get localhost:8000/fishes.php and then change it to localhost:8000/fishes.php?fish=pike (or trout).

I have directories on same project /info/pike (or trout) and in these directories there is info.txt where first line has fish latin name and second line has average size.

My question is, How can I get text from that file to "site". Code doesn't include html-code, I don't have the code right now with me. But it is fine and runs normally.

Thanks

   <?php
        $species = $_GET["fish"];
        if (file_exists("info.txt")) {
        $array = explode("/n", file_get_contents('$species/info.txt'));
        $name = $array[0];
        $size = $array[1];
        } else {
        }

        global $name;
        global $size;

        ?>


         <h1><?php$name?> (<?php$size?>)</h1>

In your Markup, you're opening the php tag, and calling a variable. This variable is not actually printing to the STDOUT. You have a few options:

<?php echo $name; ?>

or

<?php print $name; ?>

or if you have shorttags enabled

<?=$name;?>

You need to use echo or print for variables.

 <?php
        $name = '';
        $size = '';
        $species = $_GET["fish"];
        if (file_exists("info.txt")) {
            $array = explode("/n", file_get_contents('$species/info.txt'));
            $name = $array[0];
            $size = $array[1];
        } else {
            //Code for Else
        }

        //global $name; //No Need of Globals if you have html in same file
        //global $size; //No Need of Globals if you have html in same file

        ?>


         <h1><?php echo $name?> (<?php echo $size?>)</h1>

I think you need to use double quotes in "$species/info.txt"

if you server support short tags you can:

<h1><?=$name;?> (<?=$size;?>)</h1>