Welcome Guest, Not a member yet? Register   Sign In
Include a extern php file...
#1

[eluser]Unknown[/eluser]
Hi..

I´m trying to include a extern php file, I received no error messages em I use this:
include(base_url().'public/includes/funcoes.php');
The path exists and the file is there!

but when I try to access a method function of the file 'funcoes.php' I got the php error:
Fatal error: Call to undefined function ConverteDataBR() in C:\projetos\web\ci\system\application\views\busca.php on line 32


Somebody can reply me?

Thanks...
#2

[eluser]Unknown[/eluser]
I don´t know if it is right but I used this topic [http://ellislab.com/forums/viewthread/55212/] to resolve this...

So, I created a file named funcoes_helper.php on the /helpers and called in the VIEW file with
Code:
$this->load->helper('funcoes' );
.

Is it right?

see ya...
#3

[eluser]Rick Jolly[/eluser]
[quote author="Troian" date="1184036478"]
I´m trying to include a extern php file, I received no error messages em I use this:
include(base_url().'public/includes/funcoes.php');
[/quote]

Use the constant APPPATH instead of base_url(). When you include a php file using the url through http, the file will be executed and the result will be included. That is not normally what you'd want.

However, using a helper as you have (or a library) is the CI way to include functions and classes. You can call the functions in the view, but it is probably best to load the helper in the controller.
#4

[eluser]Colin Williams[/eluser]
Sounds like you have a file with a class defined in it, and you're including the file, but not instantiating the class. Just put it in the Library folder and you've got a library.




Theme © iAndrew 2016 - Forum software by © MyBB