S
S
Sergey Titov2015-10-24 23:22:29
PHP
Sergey Titov, 2015-10-24 23:22:29

Analogue of file get contents for php processing?

There is such a thing:
$content = file_get_contents($path);
If there is a php script in this $path, then it does not process it, but simply pulls out the request text itself, as I understand it logically, the file is the same, eprst. So here's a question, how can I fix this thing so that the php code is processed?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mark Doe, 2015-10-24
@Nuboskill

If I understand you correctly - you need to execute the code from the file that is in $path
Then you should use eval

$content = file_get_contents($path);
eval($content);

V
v- death, 2015-10-24
@vGrabko99

ini_set("allow_url_fopen","1");
include 'http://www.example.com/file.php?foo=1&bar=2';

The include construct allows you to include remote files if this option is enabled in the PHP configuration file.
In order for remote inclusion of files to be available, it is necessary to set
allow_url_fopen=1 in the configuration file (php.ini)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question