Home > Backend Development > PHP Tutorial > PHP中关于双引号和单引号的有关问题

PHP中关于双引号和单引号的有关问题

WBOY
Release: 2016-06-13 13:21:22
Original
789 people have browsed it

PHP中关于双引号和单引号的问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$this->view->baseUrl = $this->_request->getBaseUrl();
echo '<a href="'.%24this->view->baseUrl.'/index/index/">返回</a>';
echo "<a href="%24this-">view->baseUrl/index/index/>返回</a>";

Copy after login

以上两句echo语句有什么区别?第一句正确,第二句报错,报错内容是:Catchable fatal error: Object of class Zend_View could not be converted to string

这一句'.$this->view->baseUrl.' 加了单引号又加两个点,真是搞不懂,菜鸟,希望朋友们帮帮忙

------解决方案--------------------
echo "view->baseUrl}/index/index/>返回"; //这样写
'.$this->view->baseUrl.' //拼接字符串
------解决方案--------------------
参看:
PHP code
<?php class foo
{
    public $a;
    
    function __construct(){
        $this->a='aaaaaaaaaaaaa';
    }
}

$f=new foo();

echo "BBB{$f->a}BBBBB";

?> <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template