Jump to content

Getting the value of a PHP document


plznty

Recommended Posts

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.