title: Is it possible to use a variable inside a PHP function without passing it?
body: <p>So I'm creating my own personal calendar web app and I'm running into an issue with variables within a function. At the moment my app starts with pulling the time and finding out the month, day, and year of today's date.</p>
  
  <pre><code>$year = date("Y",time());
  $today = date("j",time());
  $month = date("m",time());
  </code></pre>
  
  <p>Later in the app I have a function to "draw" each calendar square.</p>
  
  <pre><code>function thisDay($input) {
      date("m",mktime(0,0,0,$month,$input,$year));
      echo //html stuff here;    
  }
  </code></pre>
  
  <p>Now I can pass all three variables ($month,$input,$year) because I'm using the function in a while loop.  But I've run into this before in other projects I've worked on.  I have a function to make my life easier, but I keep having to pass a half dozen variables each time I use the function even though some of them rarely change.  </p>