I 开发者_C百科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">
<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 I call it using:
echo classname->setupHead($title);
nothing gets displayed.
Doesn't PHP allow HTML in strings?
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);
Check the source - it's being output, but none of this code is rendered in the browser! It's only head data etc.
精彩评论