Професионална програма
Loading...
+ Нов въпрос
office_kanev avatar office_kanev 6 Точки

Problem with PhpStorm

Kolegi nqkoi ima li si na predstava zashto vyv PhpStorm  php- code in to html -file not working but  php code in to php-file is running in to browser

 

tova e v html - file 

test.html

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>musaka</h1>
<?php
    $myname = 'Dragan';
    echo 'My name is ' . $myname;
?>
</body>
</html>

browser -izpisva samo 'musaka'

==================================================================================

a kogato run -a   

test.php

 

<?php
$myname = 'dragan';
echo 'My name is ' . $myname;
?>

 

output:    My name is dragan

 

 

Тагове:
0
PHP Fundamentals
fbinnzhivko avatar fbinnzhivko 1582 Точки

To run PHP scripts, you have to save the file as a .php file. You will also need to execute it on a server. You can't run php directly from your browser, since PHP is a HTML preprocessor - your browser has nothing to do with PHP, it only gets the HTML that is generated by the server.

So because PHP tags are not valid in HTML files, when not preprocessed by the server, the browser doesn't recognise it, so it automatically converts it to comments since it doesn't know what else to do with it.

1
office_kanev avatar office_kanev 6 Точки

Thank you for fantastic and exhaustive answer.

0