PHP | preg_match():未知修饰符';(';在C:\xampp\htdocs\Folder\index.php的第38行

PHP | preg_match():未知修饰符';(';在C:\xampp\htdocs\Folder\index.php的第38行,php,lightopenid,Php,Lightopenid,我尝试让人们使用以下代码使用steam登录: <?php require './includes/lightopenid/openid.php'; $_STEAMAPI = "MyKey"; try { $openid = new LightOpenID('localhost'); if(!$openid->mode) { if(isset($_GET['login'])) { $openid->identity

我尝试让人们使用以下代码使用steam登录:

<?php
 require './includes/lightopenid/openid.php'; 

$_STEAMAPI = "MyKey";

try {
    $openid = new LightOpenID('localhost');
    if(!$openid->mode) {
        if(isset($_GET['login'])) {
            $openid->identity = 'http://steamcommunity.com/openid/?l=english';
            header('Location: ' . $openid->authUrl());
        } else {
            echo "<h2>Connect to Steam</h2>";
            echo "<form action='?login' method='post'>";
            echo "<input type='image' src='http://cdn.steamcommunity.com/public/images/signinthroughsteam/sits_small.png'>";
            echo "</form>";
        }
    } elseif($openid->mode == 'cancel') {
        echo 'User has canceled authentication!';
    } else {
        if($openid->validate()) {
            echo "User is logged in.\n";

                $id = $openid->identity;
                $ptn = "/^http:\/\/steamcommunity\.com\/openid\/id/(7[0-9]{15,25}+)$/";
                preg_match($ptn, $id, $matches);      
                $url = "http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=$_STEAMAPI&steamids=$matches[1]";
                $json_object= file_get_contents($url);
                $json_decoded = json_decode($json_object);
                foreach ($json_decoded->response->players as $player) {

                }

        } else {
            echo "User is not logged in.\n";
        }
    }
} catch(ErrorException $e) {
    echo $e->getMessage();
}

?>
您的图案中在“/”之前忘记了一个“\”:

$ptn = "/^http:\/\/steamcommunity\.com\/openid\/id\/(7[0-9]{15,25}+)$/";

因此php认为“/”是一个修饰符:

最好在这里发布代码,而不是链接它。而且您可能错过了
id
之后斜杠上的转义。代码应该在问题中,而不是在外部网站上。我已经为您编辑了它。