我正在尝试将$user
定义为页面所在目录名称的变量传递给页面上的 iframe。
该变量$user
应该将用户名传递给 iframe,以便 iframe 可以下载用户的 minecraft 皮肤并显示它。当我用用户名替换 iframe 中的变量但 iframe 识别$user
为$user
...时,此代码有效
主页面:
<link rel="stylesheet" type="text/css" href="/css/index.css" />
<?php
$path = DIRNAME($_SERVER['PHP_SELF']);
$position = STRRPOS($path,'/') + 1;
$user= SUBSTR($path,$position);
$root="/";
include ($_SERVER['DOCUMENT_ROOT'].'/menu/nav.php');
echo '<iframe src="skin.php?user=$user" width="200" height="400" align="left"/>'
?>
内嵌框架:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php $user = $_GET['user']; ?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script>
<script src="/js/excanvas.js" type="text/javascript"></script>
<script src="/js/minecraftskin.js" type="text/javascript"></script>
<script type="text/javascript">
$(function() {
$(".mc-skin").minecraftSkin();
});
</script>
</head>
<style>
* {
margin:0;
padding:0;
}
div {
display:inline-block;
}
.minecraft_head .head {
display:none;
}
.minecraft_head:hover .hat {
display:none;
}
.minecraft_head:hover .head {
display:inline-block;
}
.scratch {
display:none;
}
</style>
<body>
<span class="mc-skin" data-minecraft-username="<?php echo $user; ?>"></span>
</body>
</html>
我该如何纠正?