echo 'your word is '.$s;

解决方案 »

  1.   

    echo 'your word is '.$s;
      

  2.   

    还有一种,比如变量在字符串中间
    echo 'your word {$s} is';
      

  3.   

    谢谢大家的回答,加点的方法我也知道,不过这个太麻烦太乱了。不过楼上的回答正式我感兴趣的答案,我在php网上手册里的例子中也看到过这种加{}的写法,不过我自己在机器上试验了,不行啊。我用的是php5
      

  4.   

    echo 'your word is '.$s;
      

  5.   

    echo 'your word is {$s}'; --> echo "your word is {$s} ";
    单引号中是什么就输出什么。
      

  6.   

    如果你非要用单引号
    那么就eval或者字符替换
      

  7.   

    用双引号  echo "your word is ".$s."";
      

  8.   

    双引号内可以直接用
    >>> $i = 5;
    >>> print "now, i is $i ";now, i is 5如果是单引号,需要使用“.”来连接>>> print 'now, i is ' . $i;now, i is 5