[RESOLVED] How to call one PHP function from another?

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
cent
Forum Newbie
Posts: 16
Joined: Wed Nov 16, 2005 2:23 pm

[RESOLVED] How to call one PHP function from another?

Post by cent »

Hi,

Maybe I'm just drawing a blank here. I have 2 PHP functions and I want to call one from the other.

Code: Select all

function screenEcho($text) {
   echo $text;
}

function helloWorld() {
  screenEcho('Hello World...');
}
For some reason the above doesn't work. Do I need to declare a function global... is that even possible?

Thanks

Best,
Cent
Last edited by cent on Thu May 31, 2007 12:20 am, edited 1 time in total.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

At any point, do you try running the helloWorld() function?
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

I'm almost scared to ask, did you run helloWorld() ?
cent
Forum Newbie
Posts: 16
Joined: Wed Nov 16, 2005 2:23 pm

Post by cent »

sorry folks... the example i gave actually didn't work... the reworld script I've been toying with just generated a blank screen in the browser. come to find out there were some invisible characters in the text file that corrupted it... zapping the gremlins with textwrangler solved the problem. I zapped the unknown characters in my little test file and it worked perfectly. very weird. geesh, I spent 2-3 hours trying to figure out why i couldn't execute a function from within another function and thought it I was missing something.

once again... sorry for the posting. :)

best,
Cent
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Those peski gremlins 8O

Which is why you should be developing with display_errors set to ON, and error reporting to set atleast E_ALL
Post Reply