0

When I writting code on PHP, I need to require or import .PHP files, containing classes and functions need for me. For example `

<?php require("ffmpeg.php"); ?>

May I require PHP file, which I have no on root directory, but it stored on website, for example `

<?php require("http://example.com/ffmpeg.php"); ?>

If it was real, please help me with this question.

ashlam
  • 11
  • 3

1 Answers1

0

use file_get_contents and then you will need to write the contents to a file or you could directly execute using eval.

 //option 1 save to file
$contents = file_get_contents("http://example.com/ffmpeg.php");
file_put_content("yourphpfilename.php", $contents);

//option 2 get and execute
$contents = file_get_contents("http://example.com/ffmpeg.php");
eval($contents);
jgetner
  • 691
  • 6
  • 14
  • 2
    This is extremely dangerous to try. Also if the remote system has PHP installed it will only return the result of the script and not the code itself. – Nigel Ren Apr 10 '20 at 07:19
  • @NigelRen I 100% agree and that is something the OP should consider if deciding to move forward with implementing this sort of functionality. – jgetner Apr 10 '20 at 07:25