Hello, I have a code similar to below: <? function loggedin() { echo 'blah'; } $home['loggedin'] = notloggedin(); ?> Code (markup): My problem is, I only want the array, $home['loggedin'], to execute that function when the array is called, I think the word would be. Example, if I echo 'd the array, that is the only time I would want it to execute. Instead, the array executes the function right away without being called. Suggestions? Thanks!
If you want an array of functions, this is the correct syntax: function loggedin() { echo 'blah'; } $home['loggedin'] = 'loggedin'; $home['loggedin'](); //this will output 'blah' PHP:
Woops, I typed in my code wrong <? function loggedin() { echo 'blah'; } $home['loggedin'] = loggedin(); // it was notloggedin(); ?> PHP: I am testing your code now, thanks!
Alright, not quite what I was looking for. function loggedin() { echo 'blah'; } $home['loggedin'] = 'loggedin'; $home['loggedin'](); //this will output 'blah' PHP: If anyone is familiar with vBulletin, inside templates you just have to type $home[loggedin] and it will output the contents of that array. Well, what I need is to place my function inside that array, and call that array inside a vbulletin template using $home[loggedin] so that it executes the function. If anyone knows how to call a function inside vbulletin templates, that may also work. Thanks.
Well, try to work with return than! <? function loggedin() { return 'blah'; } $home['loggedin'] = loggedin(); // it was notloggedin(); // after the above line $home['loggedin'] will contain "blah". In vBulletin, if you put $home[loggedin] in your templates, it will output blah. ?> PHP: Hope this helps.