Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Switch statements to display different pages / writing the HTML

Status
Not open for further replies.

rizza

Programmer
Jul 16, 2002
66
US
I've built a bunch of pages like this in asp

<%
Select case &quot;FORM&quot;
case &quot;whatever&quot;
%>

lot's of html

<% case &quot;this&quot; %>
lot's more html

<% case else%>
last of html

<%end select%>

Is it possible to break out a switch statement in PHP? If not how do you deal with all the html. I would not have to re-type everthing using the

echo&quot;<table width=\&quot;100\&quot;>&quot;; instead.

It just seems that there has to be a better way to deal with HTML in php apps. I would be of no use to use a Editor like Dreamweaver then. Unless i just answered my own darn question using includes. But even then if you want to update one page you would have to find the correct include and then change that. And if you had like ten includes and where doing a overhaul of some kind that would be a pain.

rizza
Confused a little??? I know i am???
 
Yes, you can break out a switch statement in PHP. Watch DreamWeaver when editing files from *nix boxes -- it doesn't handle *nix ends of lines well.

Something I feel needs mentioning -- those context switches between ASP parsing mode and HTML output mode. You do know that's a real performance degrader on IIS, right?
______________________________________________________________________
TANSTAAFL!
 
Why don't you keep the page all PHP and clean looking like this

<?php
define(PAGE_HOME, 1);
define(PAGE_PROD, 2);
define(PAGE_LINK, 3);

include(&quot;inc/page_head.php&quot;);

switch($page){//page is query variable
case PAGE_HOME: include(&quot;inc/cont_home.php&quot;); break;
case PAGE_PROD: include(&quot;inc/cont_prod.php&quot;); break;
case PAGE_LINK: include(&quot;inc/cont_link.php&quot;); break;
}

include(&quot;inc/page_foot.php&quot;);
?>

and put all of the html (/php mix) in the include files, out of the way of you main logic.
 
Well, i didnt realize that switching like that was such a performance issue on IIS. Oh well, i use that with the company intranet site anyway...

As for the PHP...

I guess i could really try and begin to rework the site to make better use of all that stuff.

My biggest problem is my layout is all wierd and screwy with the tables...to get to line up right and stuff.

Thanks to all for their help,

Just out of curiosity what kind of performance issue are we talking about , by breaking in and out of code....

rizza
 
I don't remember the exact numbers. It was in a Microsoft whitepaper I read a couple of years ago. It took me nearly 3 days to dig it out of Microsoft's website.

The performance hit is significant. Enough so that Microsoft strongly recommended staying in ASP mode and creating output through Response.write() statements.

The article also mentioned performance hits caused by very long ASP files, too. The ASP interpreter is apparently not very efficient. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top