Jump to content

simple include problem


Recommended Posts

I got this really huge file (lets say its called index.php).

i i decided to cut it into chunks.

basically. im wondering with this code

<?php


if($_GET['do']=="test"){
include ("include_test.php");

if($_GET['do']=="test2"){
include ("include_test2.php");
}

?>

if i just access index.php, it will only load index.php.

my question is...will it also load include_test.php and include_test2.php and just NOT show it?
or...obviously with the if statement, it will only include include_test.php if do=test.

i know my question is simple, but i needa make sure. i needa reduce my bandwidth usage and i think this one is a simple solution

i cut the original file from 450 kb to now only 35 but it has a lot of includes. i need to know if it loads the includes and just not show it (hence bandwidth is not really reduce) or it only loads it only if the IF statement is true. thank you. i hope youunderstood my question
Link to comment
Share on other sites

If your file is 450Kb it wont be taking any bandwidth as it isnt acutlly sending that 450Kb file to the client. The thing that uses the bandwidth is the ouput, For example if you had a php script which is 1MB in size and all it did was return a simple hello world message which will come to less than 1K. It'll only take 1K out of your alloted bandwidth.

The only problem that will happen is the amount of time it'll take PHP to parse the 1MB file.
Link to comment
Share on other sites

[!--quoteo(post=385930:date=Jun 20 2006, 05:11 AM:name=wildteen88)--][div class=\'quotetop\']QUOTE(wildteen88 @ Jun 20 2006, 05:11 AM) [snapback]385930[/snapback][/div][div class=\'quotemain\'][!--quotec--]
If your file is 450Kb it wont be taking any bandwidth as it isnt acutlly sending that 450Kb file to the client. The thing that uses the bandwidth is the ouput, For example if you had a php script which is 1MB in size and all it did was return a simple hello world message which will come to less than 1K. It'll only take 1K out of your alloted bandwidth.

The only problem that will happen is the amount of time it'll take PHP to parse the 1MB file.
[/quote]

thank you!

but still, there are functions that only work on some of the DO= something pages and its loading everytime the that page is accessed. i made it require a function_test.php file with an IF statement.

thank you for your reply.

i still need answer to my question though.

Link to comment
Share on other sites

Abouty your question. PHP will not include include_test.php or include_test2.php by defualt, Unless 'do' is set to either 'test' or 'test2' in the address bar. As thats what the if statment does. it will only execute what is between the curly braces {} if the condition is true.

Also you might want to look into switch/case statements:
[code]if(isset($_GET['do']))
{
    switch($_GET['do'])
    {
        case 'test':
            include 'include_test.php';
            break;

        case 'test2':
            include 'include_test2.php';
            break;
    }
}[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.