我的PHP的hash_algos()函数不再有效

I'm not entirely sure what version of PHP, but I'm thinking it's in the 5.2 (Relatively new installtion of XAMPP). There was a certain site I built and it relied heavily on the php function hash_algos() to populate a drop down list, but it seems as of late that the hash_algos() returns absolutely nothing. Also, using windows, if XAMPP didn't give it away.

The site used to work, but doesn't anymore, and I'm not sure why, I haven't changed anything in the code. Here's the part of the site that isn't working

<select name="method" id="method">
<?
foreach(hash_algos() as $m)
{
echo "<option value=\"".$m."\">".$m."</option>";
}
?>
</select>

You need to have the Hash PECL package enabled.

This question may be of use to you: How to switch hash_algos() on ? I'm with Php 5.2.11

Edit: Since you're on Windows, you'll likely have to compile the "Hash" package yourself. It appears to be available on the PECL website but is no longer maintained.

To compile from source, PHP has a step by step guide.

After you've compiled the DLL or got ahold of one, you need to add it to your php.ini file.

You'll need to add a line like the following:

extension=php_hash.dll

More information is available on PHP's Windows site.

you forget

<?php ?>

syntax so

<html>
    <head></head>
    <body>
        <select name="method" id="method">
            <?php
                foreach(hash_algos() as $m)
                {
                    echo "<option value=\"".$m."\">".$m."</option>";
                }
            ?>
        </select>
    </body>
</html>

start server and run.