Why do we embed PHP code in HTML? Why not put the code in a separate file, just as we do with C and Java? Please give your explanation.
(Reminder: be concise.)
From the aspect of dynamic pages: We use PHP to produce dynamic pages, whose content can be changed through time and interactions with users. To achieve that ,timeliness is required. Fortunately, when embedding PHP into HTML, the efficiency is better than other CGI which entirely produce HTML mark-ups. Additionally, this embedding can help developers combine both the dynamic and static part of the pages and focus on them together or separately.
By contrast, putting different code seperately in C/JAVA is meant for modularization and better development ,which is different from the reason why we put PHP into HTML document. After all, We choose different ways to apply our code better according to different situations.
“timeliness is required” not quite sure what it means.
“the efficiency is better” –> “it is more efficient“
“focus on them together or separately” not understandable.
“We choose different ways to apply our code better according to different situations.” –> “each approach has its pros and cons.“