If an include() is conditional, will PHP include the file even if the condition is not met? -
this has been on mind quite time , figured should seek reply experts. want know if poor programming technique funnel php requests through single file. have been working on website , not sure if scale growth because not 100% of how php handles include()
function.
to improve explain how have build quasi framework here snippet of root .htaccess
file:
# > standard settings rewriteengine on # ignore media requests rewriterule ^media/ - [l] # funnel requests model rewriterule ^(.*)$ _model.php [qsa]
so except content within media directory passed single script.
inside _model.php
have input sanitisation, user authentication, session info gets pulled database, global variables (commonly used variables $longtime, $longip etc...) set. requests routed via interpreting $_server["request_uri"]
variable.
essentially have switch()
statement chooses module include()
. don't understand is: when php executes, execute every single include()
regardless of whether or not case directive true?
i concerned after time have lot of these modules - , if php @ runtime include modules end occupying much processing powerfulness , ram...
--
edit: asking if php 'read' files potentially might have include. know shouldn't execute code. if 1 of include()
2gb file takes long time process, php read on file before executing?
-- edit: have found similar question (i did search lot before posting one) php behavior of include/require within conditional
i think can close off.
no, php execute include in moment code fragment reached.
this quite important, because can have php include file code directly. e.g.
file1:
<?php echo "foo"; ?>
file2:
<?php echo "before"; include("file1"); echo "after"; ?>
sometimes php processor won't know @ compiletime file include. imagine include("file".mt_rand(1,10));
. php won't know filename include moment reaches include statement.
php
No comments:
Post a Comment