Welcome to Dream.In.Code
Become a PHP Expert!

Join 136,930 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 1,773 people online right now. Registration is fast and FREE... Join Now!




How to Define a Function to my main PHP File?

 
Reply to this topicStart new topic

How to Define a Function to my main PHP File?

atomiccafe
14 Mar, 2008 - 09:35 AM
Post #1

New D.I.C Head
*

Joined: 11 Mar, 2008
Posts: 9

I need please help please .

I have a function in my inc file in the /inc directory. This function generates a random image when the browser is refreshed.
the filename is mycode.inc

How do I call that function to show up in my index.php?

I can call <?php include ("inc/mycode.inc"); ?>

and the random image appears but how about if I have more than 1 function in my "mycode.inc" file?

I searched and read everywhere but I hit a wall.

Please help.


Thanks

This post has been edited by atomiccafe: 14 Mar, 2008 - 09:36 AM
User is offlineProfile CardPM
+Quote Post

MitkOK
RE: How To Define A Function To My Main PHP File?
14 Mar, 2008 - 09:45 AM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Aug, 2007
Posts: 314



Thanked: 12 times
Dream Kudos: 250
My Contributions
mycode.inc

php
<?php

function generate()
{
//code here ...
}

function show()
{
// code here ...
}

?>


Other php file :

php
<?php

include("mycode.inc");

generate(); // call generate function

show(); // call show function

?>


What is bodering you ?
User is offlineProfile CardPM
+Quote Post

atomiccafe
RE: How To Define A Function To My Main PHP File?
14 Mar, 2008 - 11:01 AM
Post #3

New D.I.C Head
*

Joined: 11 Mar, 2008
Posts: 9

Thanks a lot I'll try this. smile.gif


QUOTE(MitkOK @ 14 Mar, 2008 - 10:45 AM) *

mycode.inc

php
<?php

function generate()
{
//code here ...
}

function show()
{
// code here ...
}

?>


Other php file :

php
<?php

include("mycode.inc");

generate(); // call generate function

show(); // call show function

?>


What is bodering you ?


User is offlineProfile CardPM
+Quote Post

atomiccafe
RE: How To Define A Function To My Main PHP File?
14 Mar, 2008 - 11:23 AM
Post #4

New D.I.C Head
*

Joined: 11 Mar, 2008
Posts: 9

It works smile.gif thank you very much.


User is offlineProfile CardPM
+Quote Post

MitkOK
RE: How To Define A Function To My Main PHP File?
15 Mar, 2008 - 12:17 AM
Post #5

D.I.C Regular
Group Icon

Joined: 9 Aug, 2007
Posts: 314



Thanked: 12 times
Dream Kudos: 250
My Contributions
You're welcome wink2.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 10:34PM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month