PHP 无法检查条件


PHP failing to check conditions

im 正在处理一个基于 URL 显示 Minecraft 面孔的脚本,但我遇到了一个问题,每次输入无效的用户名时,它都会将其保存到 skins 文件夹中,只有在用户名有效时它才应该这样做。完整脚本:

Sorry, the problem has been already solved, i'm not going to give my script away.

我知道它很长,但这是完整的脚本。所以我提醒,问题是脚本也保存了无效的用户名,只有在用户名有效时才应该这样做。

尝试在 else{ } 语句中添加包装所有其他代码的退出

 if(!$src){
    $src = imagecreatefrompng("http://s3.amazonaws.com/MinecraftSkins/char.png");
    //here's where my problem, i am trying to only display the image on screen if not found, but for some reason it saves it into the skins folder
    imagepng($final);
    **exit();**
    }

您可以使用由 minotar 制作的预先存在的 api;为了得到我的皮肤"Phyore",当Minotar无法识别用户名(不存在)时,你会使用 https://minotar.net/avatar/Phyore,它会给你史蒂夫头。

$user = 'Phyore';
//Size defaults to 180 x 180
$size = '100';
echo '<img src="https://minotar.net/avatar/'.$user.'/'.$size.'"';

在 https://minotar.net/查看更多信息 他们甚至做全皮。