Професионална програма
+ Нов въпрос
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 



<!DOCTYPE html>
<html lang="en">
    <meta charset="UTF-8">
    $myname = 'Dragan';
    echo 'My name is ' . $myname;

browser -izpisva samo 'musaka'


a kogato run -a   



$myname = 'dragan';
echo 'My name is ' . $myname;


output:    My name is dragan



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.

office_kanev avatar office_kanev 6 Точки

Thank you for fantastic and exhaustive answer.