CodeIgniter Forums
Help on including remote php file - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Help on including remote php file (/showthread.php?tid=13163)



Help on including remote php file - El Forum - 11-13-2008

[eluser]esthonwood[/eluser]
Hi, I'm confused! I need to include a remote php file containing some functions I need (http://www.sample.com/functions.php) and i don't know how and where to put it. Here's my controller code:

Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();            
        
    }

    function index()
    {        
        include('http://www.sample.com/functions.php');
        $data['rs'] = sampleFunction();//one of the functions in http://www.sample.com/functions.php
        $this->load->view('welcome_message', $data);
    }
}

?>

I get this error - Fatal error: Call to undefined function sampleFunction().

I'm using CodeIgniter v1.7.0 and I have enabled the allow_url_include directive. I know I should put the include somewhere but i'm lost.

Any help would be greatly appreciated! Thanks guys! :-)


Help on including remote php file - El Forum - 11-13-2008

[eluser]GSV Sleeper Service[/eluser]
'allow_url_fopen' needs to be set to true before you can include remote files.
Including remote php files is a really bad idea though.


Help on including remote php file - El Forum - 11-13-2008

[eluser]pistolPete[/eluser]
Are you sure that functions.php doesn't get executed on http://sample.com ?
Open up the URL in your browser and check if you're getting the php code or just an empty page!

Apart from that, why do you need to include that php file remotely?


Help on including remote php file - El Forum - 11-13-2008

[eluser]esthonwood[/eluser]
Hi, because i'm creating a website where all data comes from sample.com. that's why i created the functions.php file.


Help on including remote php file - El Forum - 11-13-2008

[eluser]esthonwood[/eluser]
[quote author="GSV Sleeper Service" date="1226588449"]'allow_url_fopen' needs to be set to true before you can include remote files.
Including remote php files is a really bad idea though.[/quote]

yes, i have already set 'allow_url_fopen' to true Smile


Help on including remote php file - El Forum - 11-13-2008

[eluser]Lima[/eluser]
Why don't you try using XML-RPC?