Easy question to answer.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Easy question to answer.

Post by akimm »

I have a script that takes words from a form prints them to a textfile for example:

Example word = example definition
contributed by: Example person

then with explode() I take this information and place it into an array then alphabetize it and print it in different parts, like part A) is words thta begin with A and so on:

Example person#datasep#example word#datasep#example definition#entrysep#

What I would like to do is make a graphical interface to do this without having to FTP a textfile and then format it myself.

My first question for the forum is basically, if i have these functions in directory A) in textfile A) is it possble to refer to it in file B) as long as it's still in the same directory?


[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:2. Use descriptive subjects when you start a new thread. Vague titles such as "Help!", "Why?" are misleading and keep you from receiving an answer to your question.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

As long as you have permissions to get into the folders/files, open them and read them, it should be no problem to do whatever you want in them.
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

No no

Post by akimm »

I mean, can i refer to functions from one file, or do I need to actually reprint them in each file?

Would include work?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Yes, include would work...

Code: Select all

<?php
/***************
 * This page is:
 * functions.php
 **************/
function my_function()
{
    // do something
}
?>

Code: Select all

<?php
/***************
 * This page is:
 * mypage.php
 **************/

// Include our functions
// Make sure they are in the same path
// or reference the actual path that the file is in
include 'functions.php';

$my_var = my_function();
?>
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

ok

Post by akimm »

cool, thanks.
Post Reply