Hello, Is it possible to include something in string or with function ? If not, how to do that ? I have to make it in string. When I use the string, it should includes it. $include = include("file/admin.php");
i am not pretty sure, what you are looking forward to do... but, include can be used to accomplish many things. in case you want to avoid re-including the file, you can use include_once("your-include-file.php") Code (markup): you can store the filenames in a string and include them on condition if ( $condition ) { include( $include_file_a ); } else { include( $include_file_b ); } Code (markup): or you can use the code inside the include file to return a value main.php $a = $_GET['a']; $mytext = include( "include.php" ); echo $mytext; Code (markup): include.php return ($a%2) ? "odd" : "even"; Code (markup): refer http://php.net/manual/en/function.include.php Example #5 include() and the return() statement
Thanks. But I mean, how to include file instead of include("file.php"); is there anyway to include file with function or anything else ?
there is a similar function called require() http://www.php.net/manual/en/function.require.php also you can use include to include php files via "http" but i am more inquisitive about what do you want to do when you say you want to "include via function"