File private variables in PHP
<p>Is it possible to define private variables in a PHP script so these variables are only visible in this single PHP script and nowhere else? I want to have an include file which does something without polluting the global namespace. It must work with PHP 5.2 so PHP namespaces are not an option. And no OOP is used here so I'm not searching for private class members. I'm searching for "somewhat-global" variables which are global in the current script but nowhere else.</p>

<p>In C I could do it with the <em>static</em> keyword but is there something similar in PHP?</p>

<p>Here is a short example of a "common.php" script:</p>

<pre><code>$dir = dirname(__FILE__);
set_include_path($dir . PATH_SEPARATOR . get_include_path());
// Do more stuff with the $dir variable
</code></pre>

<p>When I include this file in some script then the $dir variable is visible in all other scripts as well and I don't want that. So how can I prevent this?</p>
