<!DOCTYPE html> <html> <head>
<?php include 'css.htm';?>
</head>
<body>
<?php
$pageName = basename($_SERVER['PHP_SELF']); /* Returns The Current PHP File Name */ echo "<h3> " . $pageName . "</h3> "; echo " <a href='../my-php/read_code.php?file=" . $pageName . "' target='_blank'> View Code </a>";
?>
<table background="images/bg.png" style="width:98%" style="height:640px">
<tr> <td style="width:20%"> <br>Click on the links in the menu for more PHP examples.<br>
<?php include 'menu.php';?>
</td> <td height="95%" bgcolor="white" style="vertical-align:top"> <h2>Server Path and Directory Information</h2> <b>- file name, path, server details </b> <p>A file path describes the location of a file in a web site's folder structure.<br><br> Here are some examples of PHP. This page uses the php code, <br> basename($_SERVER['PHP_SELF']); which Returns The Current PHP page Name.<br> The current page name is: <?php echo basename($_SERVER['PHP_SELF']); /* Returns The Current PHP File Name */ ?> <br> <br><br>To get your current working directory use: getcwd() <br>The working directory is: <?php echo getcwd(); ?><br><br> To get the document root directory: $_SERVER['DOCUMENT_ROOT']<br> the document root directory is: <?php echo $_SERVER['DOCUMENT_ROOT']; ?><br><br> To get the filename of the current script: $_SERVER['SCRIPT_FILENAME']<br> The filename of the current script is: <?php echo $_SERVER['SCRIPT_FILENAME']; ?><br><br> Use this php code, realpath('path.php') but insert your current page name in the parentheses to echo the real path.<br> The real path is: <?php echo realpath('index.php'); ?> <br><br>As you can see there are several ways to return the current file name, directory and path information. </p? </td> </tr> </table>
</p> </body> </html>
|