dongmi1872 2014-04-01 18:49
浏览 24
已采纳

PHP / HTML打印两个变量之间用下划线?

Hello StackOverflow Community,
I want to be able to echo that a file is uploaded in upload/FirstName_LastName_FileName.ext format. In my PHP file, I have this HTML here:

<td>File Stored in:</td>
<td>upload/$uploadName_$filename</td>

but it seems that this code returns upload/$filename. How can I remedy this situation? I'm very new to this so help is greatly appreciated!

EDIT: I was too hasty in trying to get this question answered that I didn't provide enough information. I actually could not use the PHP tags since it was going to be embedded into the message of the mail function. So I found a way by assigning a new variable $uploadPath to the code. The line now looks lke this:

   $uploadPath = "upload/" . $uploadName . "_" . $filename;
   // mail to, subject, message and its table...
   <td>File Stored in:</td>
   <td>$uploadPath</td>

Even still, thank you all for your quick answers! I gave the fastest the checkmark.

  • 写回答

3条回答 默认 最新

  • douzhe9927 2014-04-01 18:50
    关注

    There's a lot of ways to do this. Here's a few:

    <td>upload/<?= $uploadName,'_',$filename; ?></td>
    
    <td>upload/<?= $uploadName.'_'.$filename; ?></td>
    
    <td>upload/<?php printf("%s_%s", $uploadName, $filename; ?></td>
    
    <td>upload/<?= $uploadName; ?>_<?= $filename; ?></td>
    
    <td>upload/<?= "{$uploadName}_{$filename}"; ?></td>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 急matlab编程仿真二阶震荡系统
  • ¥20 TEC-9的数据通路实验
  • ¥15 ue5 .3之前好好的现在只要是激活关卡就会崩溃
  • ¥50 MATLAB实现圆柱体容器内球形颗粒堆积
  • ¥15 python如何将动态的多个子列表,拼接后进行集合的交集
  • ¥20 vitis-ai量化基于pytorch框架下的yolov5模型
  • ¥15 如何实现H5在QQ平台上的二次分享卡片效果?
  • ¥15 python爬取bilibili校园招聘网站
  • ¥30 求解达问题(有红包)
  • ¥15 请解包一个pak文件