Combine Directory and File Name in PHP ( equivalent of Path.Combine in .Net)
<p>This should be a simple question, but I just can't recall the relevant API. A search on google with the term "<a href="http://www.google.com.my/search?hl=en&amp;safe=off&amp;rlz=1C1GGLS%5FenMY291MY303&amp;q=combine%2Bdirectory%2Bname%2Bphp&amp;btnG=Search&amp;meta=">combine directory name php</a>" doesn't yield any results. So I guess I am doing both myself and the programming community a service by asking this question.</p>

<p>How to combine directory and file name to form a full file path in PHP? Let's say the directory name is "<code>D:\setup program</code>", and the file name is "<code>mj.txt</code>". The method should return me, on Windows "<code>D:\setup program\mj.txt</code>". Of course the method should return the correct file path in Linux or other OS.</p>

<p>The related function in .Net is <a href="http://msdn.microsoft.com/en-us/library/system.io.path.combine.aspx">Path.Combine</a>, but in PHP, I couldn't recall that, even though I must have seen it before. </p>
