/ Published in: PHP
URL: http://www.mechanicmatt.com/toDo/
While working on a lite project management software I started using this one method of setting a variable's value to a long string of HTML (login form module for example). You can either go through the trouble of escape all the quotation characters and when you have to edit it, unescape it, make your changes, and re-escape it... or you can simply use this method.
Expand |
Embed | Plain Text
private function printLoginForm() { $form = <<<EOT <form method="post" action="index.php"> <input type="hidden" name="component" value="login" /> <input type="hidden" name="task" value="login" /> Username:<br /> <input name="login_username" type="text" id="login_username" size="15" /> <br /> Password:<br /> <input name="login_password" type="password" id="login_password" size="15" /> <br /> <br /> <div align="right"> <input type="submit" name="login_submit" id="login_submit" value="Log-In" /> </div> </form> EOT; return $form; }
Comments
Subscribe to comments
You need to login to post a comment.

I like the idea behind it, but I like to do it a bit differently. I pass a function containing html code as a variable, so I have something like
And then I just pass the variable to a template function that uses it. What I like about that is that it pretty much lets me create an html page, that just has a little bit of extra stuff at the start and the end. As an added bonus, the text editor I use, notepad++ know to format the html as html and the php as php, so
I like the idea behind it, but I like to do it a bit differently. I pass a function containing html code as a variable, so I have something like
And then I just pass the variable to a template function that uses it. What I like about that is that it pretty much lets me create an html page, that just has a little bit of extra stuff at the start and the end. As an added bonus, the text editor I use, notepad++ know to format the html as html and the php as php, so
I like the idea behind it, but I like to do it a bit differently. I pass a function containing html code as a variable, so I have something like
And then I just pass the variable to a template function that uses it. What I like about that is that it pretty much lets me create an html page, that just has a little bit of extra stuff at the start and the end. As an added bonus, the text editor I use, notepad++ know to format the html as html and the php as php, so
Oh jeeze this comment system is retarded. It isn't making up my php code correctly, and reloading the page resent it twice. Sorry.
yeah the commenting portion leaves much to be desired sometimes. I am interested in the method you use, always interested in alternative logic. If you want, can you mail me your example? guru at mechanicmatt dot com
You can't use this one for an attribute declaration, you have to set in inside a function