ayaycaptainchris Posted June 20, 2006 Share Posted June 20, 2006 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<?phpif($_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 solutioni 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 Quote Link to comment https://forums.phpfreaks.com/topic/12443-simple-include-problem/ Share on other sites More sharing options...
hackerkts Posted June 20, 2006 Share Posted June 20, 2006 require() or require_once()try it, hope I get what you mean. Quote Link to comment https://forums.phpfreaks.com/topic/12443-simple-include-problem/#findComment-47553 Share on other sites More sharing options...
wildteen88 Posted June 20, 2006 Share Posted June 20, 2006 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 Link to comment https://forums.phpfreaks.com/topic/12443-simple-include-problem/#findComment-47590 Share on other sites More sharing options...
ayaycaptainchris Posted June 20, 2006 Author Share Posted June 20, 2006 [!--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. Quote Link to comment https://forums.phpfreaks.com/topic/12443-simple-include-problem/#findComment-47673 Share on other sites More sharing options...
wildteen88 Posted June 20, 2006 Share Posted June 20, 2006 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] Quote Link to comment https://forums.phpfreaks.com/topic/12443-simple-include-problem/#findComment-47678 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.