echo '<h1 id="mainhead">total cost</h1><p>the total cost of purchasing '.$_post['quantity'].'widget(s) '.</p>';
为什么里面的那个$_post['quantity']必须要用单引号而且连接符在单引号里面?

解决方案 »

  1.   

    purchasing '.$_post['quantity'].'widget(s)最外层用的单引号?
      

  2.   

    '<h1 id="mainhead">total cost</h1><p>the total cost of purchasing '.$_post['quantity'].'widget(s) '
    ==========================================是把
    '<h1 id="mainhead">total cost</h1><p>the total cost of purchasing '
    $_post['quantity']
    ,'widget(s) '
    这三个字符串连接起来
      

  3.   


      你要好好看看PHP的基础知识,在PHP里,‘’和“”的意思不同的,单引号是表示字符了,而双引号是函数,当然函数可以不用引号的,所以在这个句子中:<h1 id="mainhead">total cost</h1><p>the total cost of purchasing 这 串为字符,一定 要用单引号或双引号引起来。.是连结符。中间写上函数,然后又是字符