代码如下:
<?php
$path = "./";
function show_files($path){
//下面是单双引号嵌套解决方案
//echo "<label style='color:blue;background:#bbbbbb;' onclick=\"submit_info('{$path}');\">"; //解决方案1
//echo "<label style='color:blue;background:#bbbbbb;' onclick=\"submit_info('".$path."');\">"; //解决方案2
echo "<label style='color:blue;background:#bbbbbb;' onclick='submit_info(\"".$path."\");'>"; //解决方案3
echo "点击我";
echo "</label>";
}
?>
<html>
<head>
<title>文件列表</title>
<script>
function submit_info(param){
alert("ddd");
}
</script>
</head>
<body>
<form>
<?php show_files($path); ?>
<input type="hidden" id="dpath"/>
</form>
</body>
</html>