On 15 January 2004 22:39, Luke wrote:
> ? Holy cow, this gets simpler all the time. Pretty soon, there'll be
> ? nothing left on my page but PHP includes and echo functions! ?
> ? Does this cut down on a website's file size? In other
> words, are the php
> ? includes effectively inactive when no one's viewing your main pages,
> ? leaving them empty of the included pages?
>
> Well in a way yes, it wont cut down the transfer bandwitdth,
> but because you
> are reusing the same files over again, this will take up less
> disk space on
> your
> server. But the same amount of data is transferred when a
> user views the
> page (as you can see from view->source)
>
> ? But suppose there's a certain page where I don't want the
> style sheet in
> ? the middle - the one I named MIDDLE. Is there a way to mark
> it in the
> ? include page, then instruct the main page to either not import it or
> ? replace it with nothing ("")?
>
> youd have to use a variable, so in the main page do the following
>
> if($pagetoshow == 'withoutmiddle'){
> $includemiddle = FALSE;
> }else{
> $includemiddle = TRUE; //(or false depending)
> }
Euch! Very long-winded and inefficient. Much better is:
$includemiddle = $pagetoshow!='withoutmiddle';
>
> and in the include do this:
>
> if($includemiddle == TRUE){
Likewise -- this can be written more efficiently and more readbly as simply:
if ($includemiddle)
(Since $includemiddle will be TRUE or FALSE, you can use it directly in the
if () -- retrieving its value and comparing it against TRUE gives TRUE if
$includemiddle is, er, TRUE, and FALSE if it's FALSE, so doing the
comparison just wastes CPU time to reproduce the value you first thought
of.)
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php