Calling a file as a function

From: Date: Wed, 30 Aug 2000 09:19:00 +0000
Subject: Calling a file as a function
Groups: php.dev 
Request: Send a blank email to php-dev+get-31209@lists.php.net to get a copy of this message
This may seem like a silly thing, but I think it would be nice to be able to call a file as if it was a function. Lets say I have a file foo.php that I include as a footer in many of my documents. If I would like this file to do some conditional stuff based on what file includes it, that would be difficult to do since I cannot pass variables with include(). But if I could call the file as if it were a function, and could pass a variable to it like foo.php(a = "Hello world", b = 2); In foo.php two global variables ($a and $b) should then be available with the values "Hello world" and 2. Someone would probably say that I could turn foo.php into one giant function, then include foo.php and call the function. They would be right ofcourse, but with the other approach I could still include the file as usual and have the extra benefit of being able to pass variables at include time. Are there any plans to do a thing like this (or is there some obvious way to do the above that I have missed?). Best regards, Jesper Juhl juhl@eisenstein.dk

« previous php.dev (#31209) next »