[PHP] Re: Script optimisation

2002-10-16 Thread Brian McGarvie

depending on the requirements of your script, it is quicker to use ? echo
$var; ? as required, this is because php essentially ignores all the html
tags untill a ? ... ? is found for which php does it's stuff...

if you use

?
...
code
...
large echo ...; statements here and there...

?

PHP has to go thru the contents of ... and repace any variables it
finds...

however if you are echo'ing without variables always use '...' and not ...
as the single quotes state that it's just text and so it does'nt need to
parse this just output it. You can do 'some text'.$aVariable.' more text';
which will be quicker that some text $aVariable more text; to process...

As I said at the start, it very much depends on what is required for a
particular script...

Also, it is better to choose a style and stick to it! And only break your
own style when the need calls for it.

HTH,

Brian M McGarvie ([EMAIL PROTECTED][EMAIL PROTECTED])
IT/Web Apps Specialist
www.anypurposeloans.co.uk -- www.mcgarvie.net


Tony Crockford [EMAIL PROTECTED] wrote in message
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
 Hi,

 I'm sure this is an RTFM, but I'm not sure where I should be looking.

 is it quicker for PHP to execute ? echo $var ? in blocks of html or to
 echo all of the html and only have one ? and ?

 I'm using a PHP script to write a lot of html files to hard disk and the
 script execution time is climbing beyond the maximum set in PHP.ini
 (I've changed the setting, but...)

 I'm looking to shave milliseconds of each execution, any ideas, pointers
 or tutorials you could point me to.

 Thanks


 Tony




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Re: Script optimisation

2002-10-16 Thread Tony Crockford


 As I said at the start, it very much depends on what is required for a
 particular script...


Here's an area I'm struggling with:

(it's a breadcrumb trail building a href from variables according to
which page I'm creating):

?php
//index
echo a href=\, $urltoitem, /tm, $cat1_ref, /lv, $count_levels,
/index.htm\;
getcat1name($cat1_ref);
echo /abr /img src=\img/dar.gif\ alt=\ \ /br /;
//subcat1
echo a href=\, $urltoitem, /tm, $cat1_ref, /lv, $count_levels,
/s, $sub_cat1_ref, .htm\;
getsub_cat1name($sub_cat1_ref);
echo /abr /img src=\img/dar.gif\ alt=\ \ /br /;
//cat2
echo a href=\, $urltoitem, /tm, $cat1_ref, /lv, $count_levels,
/s, $sub_cat1_ref, -c, $cat2_ref, .htm\;
getcat2name($cat2_ref);
echo /abr /img src=\img/dar.gif\ alt=\ \ /br /;
//subcat2
echo a href=\, $urltoitem, /tm, $cat1_ref, /lv, $count_levels,
/s, $sub_cat1_ref, -c, $cat2_ref, -sc, $sub_cat2_ref,.htm\;
getsub_cat2name($sub_cat2_ref);
echo /a;
?

every time I mess with the -- and '--' I end up getting an error or no
output.

from what you're saying this would be a slow part of the script and as
I'm generating nearly 4000 pages atm it would be good to speed this bit
up.

how would you do it?

TIA

Tony




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php