Re: Switch statement || How to output html without using echo() or print()
| From: | Leif K-Brooks | Date: | Sat, 25 Jan 2003 17:20:09 +0000 |
| Subject: | Re: Switch statement || How to output html without using echo() or print() | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-133113@lists.php.net to get a copy of this message | ||
No. You can either echo/print with a heredoc (which is still echoing/printing, but is a lot easier) or you can exit PHP. For example:
<?php
switch($somevar){
case 'case1':
print <<< END
some html
some html
some html
END;
break;
case 'case2':
print <<< END
some html
some html
some html
END;
break;
}
?>
Or:
<?php
switch($somevar){
case 'case1':
?>
some html
some html
some html
<?php
break;
case 'case2':
?>
some html
some html
some html
<?php
break;
}
?>
CF High wrote:
Hey all. Don't know if this is possible, but here goes: I've got a simple switch statement that carries out one of several operations based on the switch statement variable value. Each operation has @ 50 lines of html -- do I have to echo or print all this html!? I'm new to PHP so pardon my ignorance here. I'm used to the relative ease of Cold Fusion............ Thanks for any ideas/suggestions, --Noah ---- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.