Darkmatter5 Posted October 20, 2008 Share Posted October 20, 2008 I have one file I include with all my functions, but there is a function in which I need to call another function from within. Meaning, I have a function that gets the sessions username from the current running sessions id. I need to echo the output of my current_user() function in my login_tool() function. How would I go about calling current_user() inside login_tool()? I'm not including the code as I think I just need to know the syntax. Thanks Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/ Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 i don't understand the problem.... function current_user ( ) { } function login_tool ( ) { current_user(); } Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670257 Share on other sites More sharing options...
Darkmatter5 Posted October 20, 2008 Author Share Posted October 20, 2008 It gives me this error: Fatal error: Call to undefined function current_user() Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670262 Share on other sites More sharing options...
Darkmatter5 Posted October 20, 2008 Author Share Posted October 20, 2008 Figured it out, just before the current_user() call I had to do this. $ec = new ecabinet(); $ec->current_user(); Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670265 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 well that's a method, not a function Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670266 Share on other sites More sharing options...
Darkmatter5 Posted October 20, 2008 Author Share Posted October 20, 2008 is this the right way to do this or do you have a suggestion as to how I should do this? Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670272 Share on other sites More sharing options...
rhodesa Posted October 20, 2008 Share Posted October 20, 2008 looks right, but without knowing all about ecabinet and what you are trying to do, it's hard to say. does it produce the expected results? Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670280 Share on other sites More sharing options...
Darkmatter5 Posted October 20, 2008 Author Share Posted October 20, 2008 Yeah it's producing what I need, I just am always wanting to streamline my code. Thanks! Link to comment https://forums.phpfreaks.com/topic/129285-calling-a-php-functino-from-within-another-function/#findComment-670285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.