0

基本上我想做的是在我的网站上有一个部分,您可以在其中提供用户的用户名,例如:NOTCH

然后它会转到 minecraft 主机并找到用户的皮肤。“皮肤窃取者”,如果你喜欢的话。

但是我遇到了一个错误,不知道如何解决它..

<?php
if ($_GET['user'])
{
$user = $_GET['user'];

if(trim($user) == '')
{
    die('No username entered!');
}

$user = preg_replace('/\s+/', '', $user);

header('Content-Type: image/png');
$picture = '<img src="http://s3.amazonaws.com/MinecraftSkins/$user.png">';
$getpicture = file_get_contents("$picture");
echo $picture
}
?>

HTML 只是读取名为“mcskin.php”的 php 页面的基本形式

4

2 回答 2

2

如果使用 file_get_contens 你只需要 url:

$picture = "http://s3.amazonaws.com/MinecraftSkins/$user.png";

也改变

$getpicture = file_get_contents("$picture");

$getpicture = file_get_contents($picture);
于 2013-03-20T17:28:56.330 回答
0

您没有使用正确的引号:

$picture = "<img src='http://s3.amazonaws.com/MinecraftSkins/$user.png'>";

在这一行中不需要引号:

$getpicture = file_get_contents($picture);

此外,您正在申请没有任何意义file_get_contents()img标签。将 URL 传递给它:

$pictureUrl = "http://s3.amazonaws.com/MinecraftSkins/$user.png";
$getpicture = file_get_contents($pictureUrl);
于 2013-03-20T17:28:24.223 回答