Newgrounds.com — Everything, By Everyone.

Checking login status…

USERNAME:

PASSWORD:

Logging in…

Logged in as:
.
Logging out…
Inbox My Account Log Out


Forum Topic: PHP include 'function' problem

(70 views • 2 replies)

This topic is 1 page long.

<< < > >>
Questioning

LonLonRanch

Reply To Post Reply & Quote

Posted at: 5/25/08 12:24 PM

LonLonRanch LIGHT LEVEL 17

Sign-Up: 05/22/05

Posts: 318

I'm currently working on a script where I use an include (); statement to add a php file that contains all my funcitons. I have another include file in the same page that loads data that makes reference to one of the funcitons, however everytime I run the script I get this message:

Fatal error: Call to undefined function write_log() in /home/mysite/www/www/example/example.php on line 37

Which means the function is undefined, even though it should be defined from the include(); statement
I have tried this page without using any include(); statements and it works fine so I'm wondering if there is something I need to be doing to my functions (is there a global function() statement or something?) Can anyone help me out?


None

RaptorIV

Reply To Post Reply & Quote

Posted at: 5/25/08 12:27 PM

RaptorIV EVIL LEVEL 05

Sign-Up: 04/21/07

Posts: 363

As long as you include the function on whatever page your using it should work.

<?
//functions.php
function MyFunc(){
echo "MyFunc!";
} ?>
<? 
//index.php
include("functions.php");
MyFunc();
?>

That will display "MyFunc!" on index.php

ok.


None

LonLonRanch

Reply To Post Reply & Quote

Posted at: 5/25/08 12:32 PM

LonLonRanch LIGHT LEVEL 17

Sign-Up: 05/22/05

Posts: 318

Hmm strangely enough changing my syntax from:

include ("file.php");
include 'file.php';

seemed to have fixed the problem, odd...


All times are Eastern Daylight Time (GMT -4) | Current Time: 08:49 PM

<< Back

This topic is 1 page long.

<< < > >>
You need a Grounds Gold Account to post on the NG BBS! If you don't have one, click here to sign up now! It's fast, free, and easy — and opens up tons of great NG features!