Placing html and php in a php variable?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mikebr
Forum Contributor
Posts: 243
Joined: Sat Sep 28, 2002 7:05 am

Placing html and php in a php variable?

Post by mikebr »

I am working on a script that contains a form, as it is complicated and probably not possible to use headers to redirect the user to different pages I am writing this script with variables to print blocks of html, one of those blocks is a login page if a new user joins up, the problem is that I am getting parse errors with a variable that contains html and php code, is this possible to do? or can a variable not contain both?

Example:

Code: Select all

$login_page='<STYLE TYPE="text/css">
<--
.style1 &#123; font-size: 11px; &#125;
.style2 &#123; font-size: 12px; &#125;
--></STYLE>
<script SOME_JAVASCRIPT>
<P ALIGN CENTER><?php include "footer.html";?></P></TD>
<TD HEIGHT=15 WIDTH=512 COLSPAN=2 VALIGN=TOP>
<P><?PHP
if empty($welcometext) &#123;
$text1="Enter your password";
&#125; else &#123;
echo "$welcometext); 
&#125;
?>
</P></TD></TR>
<TR><TD HEIGHT=20 

MORE HTML
Thanks
User avatar
Phirus
Forum Commoner
Posts: 37
Joined: Thu Apr 18, 2002 4:10 pm
Contact:

Post by Phirus »

Thats nearly impossible and to be honest pointless..

Why not just use includes and functions.

http://www.php.net/manual/en/functions.php
http://www.php.net/manual/en/function.include.php

Go do some reading..

Phirus
Post Reply