-1

I'm trying to use fucntion that defined in remote file. I add this file like this:

require_once 'http://x.x.x.x:port/file_name.php';  
// file is located at ftp-server

And I'm getting error

Fatal error: Call to undefined function func_name() in php_file.php

I used CURL function to check if file exist and it returned code 200 that means that file exists. Help please.

upd1. ini_get('allow_url_include') returned me 1.

upd2. I've tried to call this function within the file itself it works fine

Cœur
  • 37,241
  • 25
  • 195
  • 267
Frankie Drake
  • 1,338
  • 9
  • 24
  • 40

2 Answers2

2

This can be done by setting allow_url_include to on on php.ini.

Look at this answer : Can't include file on remote server

Community
  • 1
  • 1
yarek
  • 11,278
  • 30
  • 120
  • 219
  • I think the file is being included going by the error message. Also, this would be better as a comment and then flag as a duplicate if you think it is. – vascowhite Oct 23 '14 at 12:56
1

Are you 100% sure that you are getting the raw (not interpreted by the remote server) php file? Get the file using curl and print it (or simply put included file's url into browser) or change remote file's extension to e.g. 'txt' to prevent it for being interpreted.

By the way: including remote files is probably not the most secure thing in the world.

Rafał Swacha
  • 482
  • 2
  • 6
  • 20
  • Thanks. Can u advice me what to do if I need to execute function on remote server? – Frankie Drake Oct 23 '14 at 13:20
  • If your remote server supports PHP, your included file executes when You try to get it by using `require_once` (and it probably returns empty page). Put the url in your web browser and see if you are getting blank page (so the file was already executed) or php code (file was not executed on remote server). Also - as I said - _"change remote file's extension to e.g. 'txt' to prevent it for being interpreted"_. Also mind the error message - is it mentioning your local or remote file? – Rafał Swacha Oct 23 '14 at 13:25
  • Hah)) Seems that this is the solution – Frankie Drake Oct 23 '14 at 13:31