別サーバーにあるユーザー定義関数のライブラリを読み込んで使おうとするとエラーが出ます。
Fatal error: Call to undefined function my_func1() in /home/acount_name/www/test_file.php on line 6
//test_file.php
php
1//別サーバーのユーザー定義関数を読み込み 2require_once("http://example.com/functions.php"); 3 4echo "出力1"; 5 6//ユーザー定義関数 7my_func1();
//functions.php
php
1echo "ユーザー定義関数出力1"; 2 3function my_func1() { 4 5echo "ユーザー定義関数出力2";
結果
出力1ユーザー定義関数出力1 Fatal error: Call to undefined function my_func1() in /home/acount_name/www/test_file.php on line 6
test_file.php と functions.php は別々のサーバーにあるためhttp経由で読み込んでいます。
functions.php があるサーバーの php の状態を php.info で確認すると allow_url_fopen と allow_url_include ともに On になっています。
functions.php 内にある「ユーザー定義関数出力1」が出力されていることからファイルの読み込み自体はできていると思います。ただ自作した関数 my_func1() を利用しようとするとエラーが出てしまいます。
ユーザー定義関数のライブラリを二つのサーバーで共有することはできないのでしょうか?ちなみに、ライブラリがあるサーバーがメインドメイン、呼び出す側はサブドメインの関係です。
なぜエラーが出るのでしょうか。ユーザー定義関数を別サーバーから利用する方法はありませんか?
よろしくお願いします。

回答3件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。