doujian3132 2013-10-23 12:07
浏览 83

在fpdf中使用图像中的变量

I'm having an problem. please bear with me i'm new at this stuff. Here is what's happening. i want to add an image that i uploaded from php. in my php i am giving the image a random name ( giving it an order number ). the upload of the image works fine and i am getting the name i want. my problem comes in when i go to generate an pdf. in my pdf i am requesting that same (order number which i used to generate the name of the image) as a variable from my mysql and if i echo that to the screen it seems to be correct aswell. my problem is when i want to use that variable in an image in my pdf. here is my code.

//this is my order number

$pro_forma_number=$_SESSION['orderpro'];

//this is the output of the pro_forma_number

MAG132

// this is the image name

MAG132.jpg

//this is the image in the pdf

$pdf->Image('LALOGO.png',-1,-1,212); 

$pdf->Image('./upload_images/$pro_forma_number.jpg',50,50,10,);

the top one works fine but i suspect that is because i am giving it the exact file name.

i know this works if you do this..

// image directory

$imagedir=('./upload_images/MAG132.jpg');

// pdf image

$pdf->Image('$imagedir',50,50,10,);

but i have alot of images with different names and i want to invoke only the images related to set order number.

I just want to know is this at all possible or am i trying the impossible?

  • 写回答

1条回答 默认 最新

  • dongzhi2332 2013-10-23 12:10
    关注

    The most readable way using concatenation.

    $pdf->Image('./upload_images/' . $pro_forma_number . '.jpg',50,50,10,);
    

    Or simply switch to double quotes:

    $pdf->Image("./upload_images/$pro_forma_number.jpg",50,50,10,);
    

    See also: http://php.net/manual/en/language.types.string.php

    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分