Jump to content

Heredoc syntax and classes


AbstractFire

Recommended Posts

So I discovered heredoc syntax recently (<<<EOF blah blah EOF;) and I want to be able to use it.

 

Problem is that I have multiple classes (a member management class, group management, skin templates, etc.) and I want to know I can make this work across classes and such.

 

		$this->afscore->html = <<<EOF
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Admin CP</title>
	<link rel="stylesheet" type="text/css" href="{$SOURCEPATH}stylesheet_global.css" />
	<link rel="stylesheet" type="text/css" href="{$SOURCEPATH}stylesheet_menubar.css" />
	<script type="text/javascript" src="sources/admin_source/menubar.js"></script>
</head>
<body>
<!--End of Header-->
EOF;

 

The code above is part of my template class. afscore is the main class. But, if I'm in another class, It doesn't work right....

 

 

I hope I made enough sense here for someone to help me ><

Link to comment
https://forums.phpfreaks.com/topic/78652-heredoc-syntax-and-classes/
Share on other sites

Ok. Let me try this again since I wasn't thinking straight before.

 

I want to use Heredoc Syntax in my application. The problem is using it in multiple classes and trying to add to it. I have a main class that I use for database connection and other things and that is where I want to keep my variable that holds the HTML until I print it.

 

One example is that I am in a different class editing a user and want to add to the current code using heredoc.

 

$this->mainclass->html .= <<<EOF
Blah blah.
EOF;

 

Problem is when I tried this, it didn't work.

 

What do I need to do?

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.