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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.