Log in

View Full Version : Resolved document_root documentation



james438
03-19-2010, 01:51 PM
Hi, I am trying to find out more about $_SERVER['DOCUMENT_ROOT'] for example:

<?php
$image = $_SERVER['DOCUMENT_ROOT'].'/images/Council.jpg';
$imageinfo = GetimageSize($image);
echo "$imageinfo[1]<br>";print_r($imageinfo);
?>

Will produce something like:


300
Array ( [0] => 400 [1] => 300 [2] => 3 [3] => width="400" height="300" [bits] => 8 [mime] => image/png )

which is great for finding out information about an image, but when I look up the information on php.net all I get is:


The document root directory under which the current script is executing, as defined in the server's configuration file.

which just doesn't tell me much.

any idea on how or where I can find out more? Most of the results are easy enough to figure out, for example:
[0] = image height
[1] = image width
[2] = ?
[3] = width and height together in a readable format
[bits] = image color depth. (I think)
[mime] = file type

james438
03-20-2010, 12:10 AM
Sorry, this was a dumb question. $_SERVER['DOCUMENT_ROOT'] is merely a way of retrieving a file relative to the root folder as opposed to relative to the directory the script is running in.

traq
03-20-2010, 07:56 PM
did you find getImageSize() (http://us2.php.net/manual/en/function.getimagesize.php), though? very useful function. index [2] is a number corresponding to the image type, e.g., "3" means "jpg". Also, [3] is specifically designed to be used to output to <img> tags.