Re: functions and quotes
| From: | Gabe da Silveira | Date: | Wed, 22 Aug 2001 17:15:38 +0000 |
| Subject: | Re: functions and quotes | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-63937@lists.php.net to get a copy of this message | ||
Well, just off the top of my head, you seem to be mostly storing data.
None of the strings you are storing contain any variable values, so they
don't need to be double quoted. I would even take it a step further,
and move all your HTML data into raw text files, then use the readfile()
function to insert them where needed. This would make your program
logic clearer and allow easier editing of the data since they would no
longer need to have quotes escaped. It would also be faster because it
doesn't need to parse through all the data, it simply echoes what you
need to the screen. The overhead for printing multiple files is
negligible in comparison... especially if you are calling this function
from multiple pages...
In article <4.3.2.7.2.20010822125256.01bfc7a0@mail.usaexpress.net>,
kurth@usaexpress.net (Kurth Bemis) wrote:
> i'm working on a site that is going to require some fancy image switching
> based on URL called...thats part isn't a problem...the problem comes in the
> way that i'm passing the HTML from the function.
>
> My main concern here is speed with the second being workload on the server.
>
> right now the function looks like this.
>
> function tab($section){
>
> $hmenav = "<a href=\"/index.php\"
> onMouseOut=\"MM_swapImgRestore()\"
>
> onMouseOver=\"MM_swapImage('document.Nav2','document.Nav2','/images/nav/home_h
> i.gif','#931914015883')\"><img
> src=\"/images/nav/home_off.gif\" width=\"62\" height=\"16\"
> border=\"0\"
> name=\"Nav2\" alt=\"\"></a>";
>
> $comnav = "<a href=\"/company/index.php\"
> onMouseOut=\"MM_swapImgRestore()\"
>
> onMouseOver=\"MM_swapImage('document.Nav3','document.Nav3','/images/nav/com_hi
> .gif','#931914051666')\"><img
> src=\"/images/nav/com_off.gif\" width=\"79\" height=\"16\"
> border=\"0\"
> name=\"Nav3\" alt=\"\"></a>";
>
> $curnav = "<a href=\"/listings.php\"
> onMouseOut=\"MM_swapImgRestore()\"
>
> onMouseOver=\"MM_swapImage('document.Nav4','document.Nav4','/images/nav/cur_hi
> .gif','#931914075550')\"><img
> src=\"/images/nav/cur_off.gif\" width=\"113\" height=\"16\"
> border=\"0\"
> name=\"Nav4\" alt=\"\"></a>";
>
> $llsnav = "<a href=\"/lls\" onMouseOut=\"MM_swapImgRestore()\"
>
> onMouseOver=\"MM_swapImage('document.Nav5','document.Nav5','/images/nav/lls_hi
> .gif','#931914098883')\"><img
> src=\"/images/nav/lls_off.gif\" width=\"168\" height=\"16\"
> border=\"0\"
> name=\"Nav5\" alt=\"land mark land services\"></a>";
>
> $navspc = "<img src=\"/images/spacer_blank.gif\" width=\"125\"
> height=\"10\" border=\"0\" alt=\"\">";
>
> if ($section == "root"){
> $hmenav = "<a href=\"/index.php\"><img
> src=\"/images/nav/home_on.gif\"
> width=\"62\" height=\"16\" border=\"0\" name=\"Nav2\"
> alt=\"\"></a>";
> }elseif ($section == "company"){
> $comnav = "<a href=\"/company/index.php\"><img
> src=\"/images/nav/com_on.gif\" width=\"79\" height=\"16\"
> border=\"0\"
> name=\"Nav3\" alt=\"\"></a>";
> }
> print "$navspc$hmenav$comnav$curnav$llsnav";
> }
>
> section is passed to the function and the function returns the correct
> tab. IS there a better and faster way?
>
> ~kurth
>
--
__________________________________
Gabe da Silveira, Web Designer
Twin Cities Student Unions
University of Minnesota
http://www.coffman.umn.edu
wFone: (612)624-7270
eMail: jiblet@visi.com
hPage: http://www.visi.com/~jiblet