php call include inside function for outside function use -


i want include file php inside of function, used outside of function.

function add( $f ){     $i = 3;     while( $i > 0 ){         $i--;         try{             if( ( include $globals['_server']['document_root'] . $f ) == 2 ){                 break;             }             else{                 sleep( 1 );             }         }         catch( exception $e ){ }     }     die(); } 

this function automatically included auto_prepend_file.

index.php

add( '/cat.php' ); echo 'my' . $cat; 

/cat.php

$cat = 'cat'; echo '...'; return 2;       //rather not exist doesnt seem there's choice 

when index.php loaded: results in my... not my...cat.

include returns 1 if file included or not. well, if notepad++ 50% finished uploading file @ same time included, return 1 , seems includes empty file. why == 2 exists in add function.

if want include something, don't want answer you got lucky or nope, better luck next time or saving taking long, enjoy nothing, or bunch of code everywhere.

so possible? or there better alternative? can use include_guaranteed (sarcasm)? know similar questions made, answers alternatives user doing or "why" related.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -