Current location: Hot Scripts Forums » Programming Languages » PHP » Does PHP Slow Down Website Loading Time?


Does PHP Slow Down Website Loading Time?

Reply
  #1 (permalink)  
Old 01-28-06, 09:20 AM
KeYBLeR KeYBLeR is offline
Newbie Coder
 
Join Date: Jan 2006
Posts: 96
Thanks: 0
Thanked 0 Times in 0 Posts
Question Does PHP Slow Down Website Loading Time?

Does PHP Slow Down Website Loading Time?

What i'm trying to do is, make 1 php file, contain 100's of HTML examples. Then I would set it up with 100's of elseif statements. Then in my web help site, I would use php includes, to include 1 example, using urls like this,
?example=001

I'm thinking, i'm not sure, but if I call on 1 example... Does the other 100 of them still load?

Also would it be safe to call on 10 examples within the same html page.

Thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 01-28-06, 01:32 PM
robbydweb robbydweb is offline
Newbie Coder
 
Join Date: Dec 2004
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
Yes it slows it down, but it wont be noticable or barely noticable in load time. but I would use the switch() function instead of elseif, its faster that way.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 01-28-06, 02:15 PM
Patiek Patiek is offline
Wannabe Coder
 
Join Date: Nov 2003
Posts: 165
Thanks: 0
Thanked 0 Times in 0 Posts
Post

The best alternative would be to use a database, such as mysql.

However, if you decide not to you should probably use a switch statement, as already noted by robbydweb:

PHP Code:

<?


switch($request)
{
    case 
"001"// do whatever, echo or return or whatever
    
break;

    case 
"002"// whatever again
    
break;

    default: 
// nothing specified
}
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 02-15-06, 03:07 AM
doctorcracker doctorcracker is offline
New Member
 
Join Date: Feb 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
how about using exit(); func?

like

if ($example == "001") {
|| do this ||
exit();
} else if ($example == "002") {
|| do this ||
exit();
}

In this case I my self feel that if the 00x matches the first listed conditions like from 1-10 it would be fast as it would be exitting but for example=100 it still has to read till the end of the PHP file..


Please correct me if I am wroong..

Regards
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 02-15-06, 06:55 AM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
PHP Code:

<?

if ($x == 1) {
echo 
1;
}
else {
echo 
0;
}
?>
works just the same as:
PHP Code:

<?

if ($x == 1) {
echo 
1;
exit();
}
echo 
0;
?>
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #6 (permalink)  
Old 02-16-06, 10:15 PM
wirehopper's Avatar
wirehopper wirehopper is offline
-
 
Join Date: Feb 2006
Posts: 2,516
Thanks: 20
Thanked 109 Times in 106 Posts
Hi,

You can preprocess the PHP - which is like compiling or caching the dynamic page.

http://www.ddj.com/documents/s=9938/ddj0601g/0601g.html

There is a demo at: http://www.wirehopper.com/php/prepro...wirehopper.com

Another approach would be to feed the URL into the PHP and basically use the PHP to include the HTML and help into an iframe/frame or a straight PHP include. For example:

http://testdomain.com?url=example.htm

in the PHP, you could have

import_request_variables("gp","rvar_");
$url=$rvar_url.'.htm';
include $url;

// help page - or you could have an HTML link to the help
include $url.'help.htm';
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #7 (permalink)  
Old 02-17-06, 10:01 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
the whole PHP file has to be parsed first so it does make difference but probably not noticable depending on the size of those examples. I'd prefer putting each example in a file and then include it after sanitizing the URL input.
I'd suggest a Swicth() since it's much more cleaner than IF/ELSEIF/ELSE in your case.
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #8 (permalink)  
Old 02-17-06, 08:23 PM
koncept
Guest
 
Posts: n/a
i thought that there was a php function to get the total execution time
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #9 (permalink)  
Old 06-03-10, 04:57 PM
ariebsomer ariebsomer is offline
New Member
 
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Timing php

At top to create arrays and time function:

<?
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$start = $time;
?>

At bottom to process and pass values:

<?
$time = microtime();
$time = explode(' ', $time);
$time = $time[1] + $time[0];
$finish = $time;
$total_time = round(($finish - $start), 4);
echo '<p>Page generated in '.$total_time.' seconds.</p>'."\n";
?>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
2 profitable script sites for sale cms-master.com General Advertisements 3 07-03-07 11:17 AM
PHP Website advanceddesigns Job Offers & Assistance 5 09-30-05 05:36 AM
PHP multi-dimensional array sorting issue aqw PHP 2 06-25-05 12:09 AM
FS: Prozilla Memberships (Turnkey Sites) - $10-15 less than Retail! rockergrrl General Advertisements 0 08-11-04 01:05 AM
PHP Error Fairnie PHP 8 06-26-04 08:15 AM


All times are GMT -5. The time now is 12:40 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.