473,395 Members | 1,763 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

user functions

I am a bit confused by writing or using my user functions.

The only way I know at the moment to call my own functions is to put them in
one file with the main program.

this example comes from http://de.php.net/manual/de/functions.php
<?php

function foo($foo, $bar = "bar")
{
echo $foo.$bar;
}

echo foo("foo");
//gives: foobar

echo foo("foo","bar2");
//gives foobar2

?>

I would prefer one file one function. How could I do this or is this
absolutly wrong to do it this way. How did php know where to look for a
user function.

regards
Reimar

--
Forschungszentrum Juelich
email: R.*****@fz-juelich.de
http://www.fz-juelich.de/icg/icg-i/
================================================== ================
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg-i/i...lib_intro.html

Jul 17 '05 #1
2 1551

"Reimar Bauer" <R.*****@fz-juelich.de> wrote in message
news:c7***********@zam602.zam.kfa-juelich.de...
I am a bit confused by writing or using my user functions.

The only way I know at the moment to call my own functions is to put them in one file with the main program.

this example comes from http://de.php.net/manual/de/functions.php
<?php

function foo($foo, $bar = "bar")
{
echo $foo.$bar;
}

echo foo("foo");
//gives: foobar

echo foo("foo","bar2");
//gives foobar2

?>

I would prefer one file one function. How could I do this or is this
absolutly wrong to do it this way. How did php know where to look for a
user function.


Go look up include(), require() etc.

Garp
Jul 17 '05 #2
Reimar Bauer wrote:
I am a bit confused by writing or using my user functions.

The only way I know at the moment to call my own functions is to put them in
one file with the main program.

this example comes from http://de.php.net/manual/de/functions.php
<?php

function foo($foo, $bar = "bar")
{
echo $foo.$bar;
}

echo foo("foo");
//gives: foobar

echo foo("foo","bar2");
//gives foobar2

?>

I would prefer one file one function. How could I do this or is this
absolutly wrong to do it this way. How did php know where to look for a
user function.

I usually put my functions in a separate file which I include.

<?php // foo-function.inc.php
function foo($foo, $bar = 'bar') {
echo $foo, $bar;
}
?>
Then I include this file in my scripts. For instance, index.php could be

<?php // index.php
require_once 'foo-function.inc.php';

echo foo('foo');
// gives foobar

echo foo('foo', 'bar2');
// fives foobar2
?>
--
USENET would be a better place if everybody read: : mail address :
http://www.catb.org/~esr/faqs/smart-questions.html : is valid for :
http://www.netmeister.org/news/learn2quote2.html : "text/plain" :
http://www.expita.com/nomime.html : to 10K bytes :
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: markus | last post by:
This string does not work in php: $sql="UPDATE mytable SET myfield=myuserfunction(myfield)" What I want is my function to evaluate each field and put the new value in the field. For...
4
by: Tim Daneliuk | last post by:
OK, I've Googled for this and cannot seem to quite find what I need. So, I turn to the Gentle Geniuses here for help. Here is what I need to do from within a script: Given a username and a...
5
by: Ed Havelaar | last post by:
I have a cool function that I want to use as a default value for a column in my table. But I can't because apparently Access doesn't allow user defined functions in expressions for default values....
2
by: David Emme | last post by:
Access 97 I have a number of SELECT statements which contain references to user-defined VBA functions. These typically work as expected, but occasionally, on one user's machine or another,...
0
by: Jason | last post by:
I am pretty new to C# so bare with me... The design of my website utilizes tables on every page that look almost identical, save the data they are displaying. I have written the code to create...
8
by: Prince Mathew | last post by:
Hi All, I have a requirement. I am throwing an exception from my user control I want to catch this in my container page. Is this possible? I don't want any event to be raised. PLEASE...
3
by: Michael Glaesemann | last post by:
Hello all, Recently I've been thinking about different methods of managing users that log into a PostgreSQL-backed application. The users I'm thinking of are not necessarily DBAs: they're...
4
by: SAL | last post by:
Hello, I created a WebPage.aspx that has some functions in it, and I created a User Control that has a File Field Control and a Botton control on the .ascx. I added myUserControl.ascx to the...
11
by: Brad Baker | last post by:
I'm building a small web application - I started out placing all my code in one file (config.aspx). As I continue to add code though it was becoming very unwieldy. After doing some searching...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.