dpdbu24262 2015-12-22 17:51
浏览 11

PHP,无法从远程服务器调用函数

I am trying to keep my PHP code on one server, while calling the functions from a separate server.

Server 1

<?php
    echo 'Server 1';

    function testingStuff(){
        echo 'Testing Stuff';
    }

    function testingStuff2(){
        return "Testing Stuff 2";
    }
?>

Server 2

<?php
    include 'fullURLtoServer1.php';

    testingStuff();

    echo testingStuff2();
?>

I know the include statement is working, as "Server 1" is being properly echoed to the screen, but neither of the function calls displays anything. Am I missing something? Why do neither function calls work?

EDIT 1

The ideal situation would be having a single .php file on Server 1 that contains multiple functions, which I can call as often as I'd like.

  • 写回答

1条回答 默认 最新

  • doubengman2072 2015-12-22 17:56
    关注

    When you "include" a remote file, you are included the output of that file.

    For server 2, the file you are trying to include just says:

    Server 1
    

    If you want to execute remote functions, you can make a different file for each function, and execute the function when the file is called. That way, you can "include" the remote file and show the output. You can replace the "different file for each function" for a single file with a parameter.

    Keep in mind, trough, that any user/server/bot can call those functions by simply loading the file from the webserver.

    评论

报告相同问题?

悬赏问题

  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程