Why the PHP script does not run if opened by the pc, but does it run open on localhost? [duplicate]

-2

I'm already warning that I'm not with any problem and, alias, I just solved one that refers to this question but anyway, I wanted to know (out of curiosity) why a php script does not run if I open the file through the computer , but if I enter the host address it normally runs?

<html>
	<head>
		<META CHARSET="UTF-8">
		<META NAME="author" VALUE="Fernando Aguiar Pinedo">
		<LINK REL="stylesheet" HREF="css.css">
		<LINK REL="shortcut icon" HREF="favicon.ico">
	</head>
	<body>
		<div id="cabeçalho">
			<h1>Music Downloader</h1>
			<p>Download Your Music Here</p>
		</div>
		<div id="filterlist">
			<ul>
				<h1 style="font-family:calibri; margin:5px; text-align:center;">Genre</h1>
				<li>Rock</li>
				<li>Eletronic</li>
				<li>Pop</li>
				<li>Reggae</li>
				<li>Hip Hop</li>
				<li>Anime</li>
				<li>Video Game</li>
			</ul>
			<ul>
				<h1 style="font-family:calibri; margin:5px; text-align:center;">Language</h1>
				<li>English</li>
				<li>Japanese</li>
				<li>French</li>
				<li>Brazilian</li>
				<li>Chinese</li>
				<li>German</li>
				<li>Spanish</li>
			</ul>
		</div>
		<div id="content"> <!--Conteúdo Aqui-->
			<?php
				include ("connectsql.php");
				$consulta = "SELECT * FROM songs";
				$result = mysqli_query($link, $consulta) or die(mysqli_error());
	
				if($result){
					while($row = mysqli_fetch_array($result)){
						$name = $row['Song'];
			?>
			<p><?php echo "$name"; ?></p>
			
			<?php
					}
				}
			?>
		</div> 
		<!--Até Aqui-->
	</body>
</html>

In the "content" div, php does not run directly from the computer, only if it is opened by the internet by typing the localhost address.

    
asked by anonymous 19.02.2018 / 13:53

2 answers

0

PHP is a back-end* language that runs on the server usually APACHE* , the browser has no power to interpret this type of language.

What is apache? The Server HTTP Number One on the Internet, Apache HTTP Server Project is an effort to develop and maintain an open HTTP server for modern operating systems, including UNIX and Windows. The goal of this project is to provide a secure, efficient, and extensible server that provides HTTP services in sync with current HTTP standards.

  

Let's say you want to save your precious connection and develop everything   locally. In this case, you will need to install a web server, such as   o » Apache , and of course the PHP . You also probably want to install   a database such as » MySQL .

What is backend?

Back-end As the name suggests, the back-end developer works on the "back" part of the application. He is generally responsible for implementing the business rule.

In a web application, this developer, when focused, does not touch the visual part of the application. By dealing with the business rule, sometimes a systems programmer, such as commercial applications and even scientific, can be called a back-end developer. And generally, in these applications, this developer works a bit with the visual part. So for this article, the backend developer taken into account, is the web application developer.

When we talk about back-end in web development, we come across several languages, like Go, Clojure, C #, PHP, Java, Python, Ruby, among others. Each has advantages and disadvantages in relation to its use in web development as well as in the labor market.

References:

link link
link

    
19.02.2018 / 13:58
1

Why the browser can not interpret language that runs on the server side by itself. That's why we use WAMP , XAMPP , Apache, among others. This holds for any language that does Server-Side .

    
19.02.2018 / 13:57