时间:2021-07-01 10:21:17 帮助过:4人阅读
刚开始学php,写了一段文字生成图片的代码。现在发现不能将text传至php里,而且就算不传参。直接在php里定义$ment = $_POST['text'_] 也会报错:图像xxx因存在错误无法显示,肯定不是字体的问题,我快疯了..谁能帮帮我...代码如下
index.html:
- <code> <title>Logo Generater</title> </code>
https://www.gxlcms.com/logo generate.php:
- <code><!--?php$ment = 'What are you 弄啥类?'$ment = $_POST['text'];echo $ment;echo strlen($ment);$im = imagecreate(450,50);$white = imagecolorallocate($im,0,0,0);#imagecolortransparent($im,$white); $black = imagecolorallocate($im,255, 255,255);imagettftext($im,26,0,15,40,$black,'E:\xampp\htdocs\test\simsun.ttc',$ment);header("Content-type:image/png");imagepng($im);?--></code>
谢谢了...
-------------------------16:35更新-----------------------
谢谢帮助我的人~(づ ̄ 3 ̄)づ
还有个问题 能不能像这张图一样,点击OK,传参给PHP,之后还在这个界面显示图片
以下是新代码~
- <code> <title>Logo Generater</title> </code><form action="https://www.gxlcms.com/logo generate.php" method="post"><code> <h2>Logo Generater</h2> <h2>wirte by Yates WANG</h2> <label for="ment">Company name:</label> <input type="text" name="ment" id="ment"> <input type="submit" name="submit" id="submit" value="OK"> <br> <br> <img src="https://www.gxlcms.com/logo generate.php"> </code></form>
- <code> <!--?php#$ment = 'What are you 弄啥类?';$ment = $_POST['ment'];#echo strlen($ment);#$len = strlen($ment) * 30;$im = imagecreate(400,50);$white = imagecolorallocate($im,0,0,0);#imagecolortransparent($im,$white); $black = imagecolorallocate($im,255, 255,255);imagettftext($im,26,0,15,40,$black,'C:\Windows\Fonts\simsun.ttc',$ment);header("Content-type:image/png");imagepng($im);imagedestroy($im);?--></code>
再次感谢!