1, "two" => 2); // 输出:: The first element is 1 echo "The first element is $temp[one]."; ?> 但是如果后面">
输入banner图图片脚本导航/分类

教你如何在PHP字符串中加入变量_PHP教程

我们在对但是需要对PHP字符串中加入变量说明的是,尽管下面的例子没有错误:

  1. php
  2. $temp = array("one" => 1, "two" => 2);
  3. //
输出:: The first element is 1
  • echo "The first element is $temp[one].";
  • ?>
  • 但是如果后面那个 echo 语句没有双引号引起来的话,就要报错,因此建议使用花括号:

    1. php
    2. $temp = array("one" => 1, "two" => 2);
    3. echo "The first element is {$temp["one"]}.";
    4. ?>

    以上就是PHP字符串中加入变量的具体解决方法。


    www.bkjia.comtruehttp://www.bkjia.com/PHPjc/446370.htmlTechArticle我们在对 但是需要对PHP字符串中加入变量说明的是,尽管下面的例子没有错误: ? php $ temp = array ("one"= 1,"two"= 2); //输出::Thefirstelementis1...