需要从URL复制PHP文件

问题描述 投票:0回答:1

当我在PHP上编写代码时,我需要或导入.PHP文件,其中包含我需要的类和函数。例如`

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

可能需要PHP文件,该文件在根目录上没有,但是存储在网站上,例如`

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

如果是真实的,请帮助我解决这个问题。

php require
1个回答
0
投票

使用file_get_contents,然后您需要将内容写入文件,或者可以使用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);
© www.soinside.com 2019 - 2024. All rights reserved.