plznty Posted January 27, 2011 Share Posted January 27, 2011 Ive tried <?php $file = file_get_contents('./time.php'); echo $file; ?> This just outputs the php, how can I make it just the out php output value. ty in advance. Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted January 27, 2011 Share Posted January 27, 2011 include() will execute the PHP, if that's what you mean. Quote Link to comment Share on other sites More sharing options...
spaceman12 Posted January 27, 2011 Share Posted January 27, 2011 Ive tried <?php $file = file_get_contents('./time.php'); echo $file; ?> This just outputs the php, how can I make it just the out php output value. ty in advance. unless your time.php file is echoing out some vlues, it wont. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 31, 2011 Share Posted January 31, 2011 include() will execute the PHP, if that's what you mean. Building upopn BlueSkyIS's response, if you just do an include it will output any code to the page that time.php produces. However, if you want to set a variable then you can just set up time.php to do a return just like you would do in a function. Example time.php file <?php $time = date('H:m:i'); return $time; ?> Then in the page that calls time.php use something similar to what you have $file = include('./time.php'); echo $file; Note that file_get_contents() by passes the PHP parser and you will get the actual contents of the file (i.e. the code). To get the PHP parser to process the file you need to use include(), require() or one of the variants. Quote Link to comment 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.