RE: [PHP] Can Variables be in functions?

From: Date: Tue, 26 Dec 2000 17:37:52 +0000
Subject: RE: [PHP] Can Variables be in functions?
Groups: php.general 
Request: Send a blank email to php-general+get-31856@lists.php.net to get a copy of this message
> I have a function as follows: > > function myExit(){ > print("</table>$footercontent"); > exit; > } > > $footercontent does have the footer information in it because > I echo it > right before I make the function. > > when I use the function all it echoes is: </table> > > Anyone want to tell me what I'm doing wrong this time? Sure. $footcontent was never passed or declared in your function. echoing $footercontent will do nothing more than display whatever the value of $footercontent is. You need to call the function in your file. myExit(); and one thing you can do is pass the value of $footercontent by placing it in your function call. // Declare Footer $footercontent = 'End of my page'; myExit($footercontent); then in your function you will need an instance of $footercontent. function myExit(&$myfootercontent){ print("</table>$footercontent"); exit; } hope that helps. -brian d.

« previous php.general (#31856) next »