title: How to build a file path correctly by using php?
body: <p>I have a directory and a dynamic file name. Are there any functions I can use to make sure it is impossible to break out from the specified directory?</p>
  
  <p>for example:</p>
  
  <pre><code>secure_path('/tmp/', 'file.txt') -&gt; /tmp/file.txt
  secure_path('/tmp/', '../file.txt') -&gt; /tmp/file.txt
  </code></pre>