Page 1 of 1

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

Posted: Wed May 30, 2007 9:28 pm
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

Posted: Wed May 30, 2007 9:34 pm
by superdezign
At any point, do you try running the helloWorld() function?

Posted: Wed May 30, 2007 9:35 pm
by John Cartwright
I'm almost scared to ask, did you run helloWorld() ?

Posted: Thu May 31, 2007 12:19 am
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

Posted: Thu May 31, 2007 1:17 am
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