I encountered a small problem when I was learning php for the first time. I asked my predecessors to instruct me how to use c, c ++, and java. Recently, I started to learn the php scripting language because of my work, php5, apache2, and mysql are installed on ubuntu12.04. Using the book core php programming as the Getting Started Guide, I wrote the following sample script based on the examples in the book.
Save it as a. html file and open it in firefox. Only html code is displayed.
I checked it online. the netizen said that the html file was handed over to the browser for direct explanation. the browser did not recognize php and found httpd in the/etc/apache2/directory as prompted by the netizen. conf file, which is an empty file. I added two lines in the table as follows:
Php5-script. php. html
AddType text/html. php. html
It cannot be explained after restart. Then I thought that this would not work, so I could try another suffix, so I created a php file and wrote only one line.
Firefox runs normally
However, when I add html code to this. php file (suffix:. php)
Firefox only displays the html part.
In my understanding, the configuration file should be configured according to the suffix. php is handed over to the php interpreter for execution. even if only one part is displayed, the html part should be ignored and the php part should be executed. why is the opposite? I cannot understand it. could you help me, this includes how to embed and execute php in static html code.
Reply to discussion (solution)
Data turn to date
Haha data is wrong with date
Well, this is indeed a small question. thanks to my friend on the second floor of the first floor, I have already given you the score, because the first floor has already given him 30 points.