Welcome Guest, Not a member yet? Register   Sign In
Help on including remote php file
#1

[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! :-)
#2

[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.
#3

[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?
#4

[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.
#5

[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
#6

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




Theme © iAndrew 2016 - Forum software by © MyBB