tags:

views:

50

answers:

2

I have the following function below:

public function setupHead($title){

    $displayHead .='<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>'.$title.'</title>';
    $displayHead .='<script type="text/javascript" src="'.PATH.'js/jquery-1.3.2.min.js"></script>
    <script type="text/javascript" src="'.PATH.'js/thickbox.js"></script>
    <script type="text/javascript" src="'.PATH.'js/ui.core.js"></script>
    <!--<script type="text/javascript" src="'.PATH.'js/js.js"></script>-->
    <link rel="stylesheet" href="'.PATH.'css/thickbox.css" type="text/css" media="screen" />
    <link rel="stylesheet" type="text/css" href="'.PATH.'css/styles.css">
    <link rel="stylesheet" type="text/css" href="'.PATH.'css/menu_allbrowsers.css">
    <link rel="stylesheet" href="'.PATH.'css/news.css" type="text/css" media="screen" />
    <link rel="stylesheet" href="'.PATH.'css/text.css" type="text/css" media="screen" />

    <script type="text/javascript" src="'.PATH.'js/swfobject.js"></script>
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="'.PATH.'css/IE7menu.css" /><![endif]-->
    <!--[if IE 6]><link rel="stylesheet" type="text/css" href="'.PATH.'css/ie6.css" /><![endif]-->
    <!--[if IE 7]><link rel="stylesheet" type="text/css" href="'.PATH.'css/ie7.css" /><![endif]-->
    </head>';

    return $displayHead;
}   

but when it call is using:

echo classname->setupHead($title);

nothing gets displayed.

doesn't php allow html in strings?

Thanks in advance

+4  A: 

When using the operator -> you need to call it on an instance of the class

$class = new classname();
echo $class->setupHead($title);

Or you could make the function static, in which case you could then do

echo classname::setupHead($title);
Yacoby
Abdul, you should also turn on error_reporting(E_ALL) because at the very least your code should throw a notice or warning that would have helped you debug this.
Jordan
+1  A: 

Check the source - it's being output, but none of this code is rendered in the browser! It's only head data etc.

Andy