title: How to use variables outside page.open in PhantomJS
body: <p>What I want to do is to access some variables outside <code>page.open</code>, but it doesn't seem to work.</p>
  
  <p>Let's take this piece of code:</p>
  
  <pre><code>var page = require('webpage').create();
  var url = 'http://www.bing.com';
  
  var Tester;
  
  page.open(url, function(status) {
      var cont = page.content;
      var patt = /Bing/;
      Tester = patt.test(cont);
  
      console.log ("Inside " + Tester);
  
      phantom.exit();
  });
  
  console.log ("Outside " + Tester);
  </code></pre>
  
  <p>The output is:</p>
  
  <pre>
  Outside undefined
  Inside true
  </pre>
  
  <p>I would expect both values to be true, and the order to be Inside first and Outside after.
  What is going on?</p>
  
  <p>It seems that the code outside is executed before the code inside.</p>