【发布时间】:2014-09-11 23:12:37
【问题描述】:
我想从用户那里获取画布的大小。当用户给出特定的像素大小时,画布将被绘制为该大小。我正在尝试运行此代码,但它不工作。我试图得到它通过表单和 PHP 中定义的值.. 这两种方式都不起作用..
<html>
<body style=" background: lightblue;">
<?php
//@$height=['$height'];
//@$width=['$width'];
$h=420;
$w=420;
?>
<center>
<form name="test" action="Untitled-1.php">
Please enter height : <input type="text" name="height"> <br>
Please enter widht : <input type="text" name="width"> <br>
<input type="submit" value="submit" name="submit"> <br>
</form>
</center>
<!-- <canvas id="canvas" width="420px" height="420px" style="background: #fff; magrin:20px;"> -->
<canvas id="canvas" height=<?php '".$h."' ?> width=<?php '".$w." '?> Style="background: #fff;">
<!-- <canvas id="canvas" height=<?php '".$height."' ?> width=<?php '".$width." '?> Style="background: #fff;"> -->
Browser does not support canvas
</canvas>
</body>
</html>
【问题讨论】:
-
你需要在画布标签中回显你的 php 变量:
<?php echo $h; ?>