fhnaylor
fhnaylor

Reputation: 45

"Include virtual' as in Classic ASP for PHP is possible?

Is there a similar command in php simulating command in Classic ASP "include virtual" that can be applied in the command 'file' or 'include' to guide the opening of files?

I use a Windows Host not Apache.

Upvotes: 0

Views: 2087

Answers (1)

Spudley
Spudley

Reputation: 168655

ASP's #include directive allows file or virtual options, which include files using a path either relative to the current file or relative to the site root, respectively.

(More info can be found here: http://www.w3schools.com/asp/asp_incfiles.asp) (and yes, I dislike w3schools as much as the next guy here, but it was the clearest explanation I could find in a hurry; feel free to replace it if you know a better one)

PHP's include() function (and include_once(), require() and require_once()) doesn't differentiate this way. If you want to include a file using a directory relative to the virtual server root, you need to use $_SERVER['DOCUMENT_ROOT'] in your include path. ie:

 include $_SERVER['DOCUMENT_ROOT']."\myfile.php";

See the PHP manual page for more info: http://php.net/manual/en/function.include.php and http://php.net/manual/en/reserved.variables.server.php

Upvotes: 2

Related Questions