LOCALHOST is a combination of two words, namely local and host. Local means local or internal to our computer, while host means a hosting service provider. Hosting itself means a place to put files from a web server. In short, Localhost is a term to call hosting on a local computer where a web server is installed.
HTTPCS is a folder to put our PHP practice files later. this folder will be automatically created when we install XAMPP. When we call the localhost address in the browser, what appears is the compilation of the files in this HTDOCS folder.
The HTTPCS folder is located in the XAMPP folder. We can add some new folders in the HTTPCS folder. Usually these folders are a separation from the exercise or website project that we are making. How to call this folder in the browser, is different from how to call the folder on windows. For example, if we create a ¡°practice¡± folder in the HTDOCS folder, then we have to open this folder by typing localhost/training or 127.0.0.1/training. Pay attention to the ¡°/¡± sign which is different by calling the folder in windows using the ¡°\¡± sign. This is because the website system adopts a UNIX system that uses a ROOT or ¡°/¡± folder system. By default, when we call localhost we will be redirected to the XAMPP settings page. So if you type localhost in the browser, it will automatically go directly to the localhost/xampp address. This is because there is an index.php file in the htdocs folder which directs us to the xampp folder
The following is the contents of the index.php file:
<?php
if (!empty($_SERVER[‘HTTPS’]) && (‘on’ == $_SERVER[‘HTTPS’])) {
$uri = ‘https://’;
} else {
$uri = ‘http://’;
}
$uri .= $_SERVER[‘HTTP_HOST’];
header(‘Location: ‘.$uri.’/xampp/’);
exit;
?>
It is this command ¡°header(¡®Location: ¡®.$uri.¡¯/xampp/¡¯);¡± that always directs us to the htdocs/xampp folder. We can just delete this file if it bothers us. But if it’s just an exercise, then we just need to create folders in the htdocs folder and then call them directly, like the example above (localhost/practice).
Example of creating a php file in the htdocs folder:
- Create an exercise folder in the htdocs folder
- Open a php editor, for example: bluefish then click File > New
- Fill in the following text in the new file and save it in the practice folder with the name index.php
- Open a browser, for example: firefox then type localhost/training,
The need for digital IT is needed in daily activities, Bead IT Consultant is the right choice as your partner, visit our website by clicking this link: www.beadgroup.com