I am getting a problem loading php files in my chrome browser. if i try loading the file it returns the html content in the browser. and if i try loading with another browser, it works well. any help?
the html content
<?php
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no'>
<title>TEST PAGE</title>
<style></style>
</head>
<body>
<a href='logout.php'> logout</a><br>
<h2> index page</H2>
<p>hello username</p>
</body>
</html>
how the file appears in the browser
CodePudding user response:
PHP is a server-side programming language, it has to be interpreted on the server, therefore you will have to start a local web server which interprets your .php
files, from the web server address you will see the interpreted code in your browser, and you will notice that all PHP blocks <?php ?>
won't be there anymore, since the files are interpreted.
Accessing from file://
protocol therefore won't work, you have to access the web server address, for example: http://localhost
.
No browser understands PHP, since all browsers only understand HTML, CSS, JS.
CodePudding user response:
please clear the caches data from your chrom browser and the re-enter specific url in your file/folder.and make sure your saved file extention is .php