dongshi3061 2014-06-15 19:21
浏览 41

如何组合php变量和普通文本

I have a form and it has field and it`s name is application no. these is a auto increment number. i create a simple code for generate this number. now it should be show 1,2,3,4.....etc...but now i want to attach normal text to before this number...like "LN/SS- my unique id" how can i developed it! i post my code.. someone help me to solve this error. $insert_id is my variable name and i already echo in my text field(application_no)

  <?php
   $query2 = "SELECT * FROM tbl_loan_application ORDER BY application_id DESC LIMIT 1";
   $result2 = mysql_query($query2,$conn);
   $row = mysql_fetch_array($result2);
   $last_id = $row['application_id'];

   //$insert_id = $last_id + 1;
   $insert_id = ++$last_id;
   ?>
  • 写回答

2条回答 默认 最新

  • douyueju2912 2014-06-15 19:31
    关注

    I can't quite tell what you're asking for here, but I assume you mean concatenation. In that case, either of the following would work:

    echo "<text>" . $var;
    

    or

    echo "<text>{$var}";
    

    Replace

    <text>
    

    with the text you want added.

    Something like this:

    $var = "test";
    echo "Value: {$var}";
    

    or:

    $var = "test";
    echo "Value: " . $var;
    

    would both return:

    Value: test

    Edit because I saw your comment: Using the escape in a double-quoted string creates a new line. Use that if you want your data to be printed across multiple lines. I.E:

    echo "<text>{$var}
    ";
    echo "<text>{$var}
    ";
    

    would return

    (text)(value of $var)

    (text((value of $var)

    Note the new line that is created.

    评论

报告相同问题?

悬赏问题

  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效