[phpwebapp-discussion] [phpwebapp - Web Application Discussion] RE: Mixing HTML, CSS, JavaScript, PH
Brought to you by:
dashohoxha
From: SourceForge.net <no...@so...> - 2003-07-31 09:27:13
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=2129012 By: dashohoxha The HTML syntax offers a possibility to take out the JavaScript code and the CSS code in separate files. It is like this: <script language="javascript" src="file.js"></script> <link rel="stylesheet" href="file.css" type="text/css" /> However there is no standard way to clearly separate the HTML, PHP and SQL codes. You can try to keep the degree of mixing of HTML and PHP code at a minimum level by carefully designing the application. E.g. you can place all the PHP code unrelated to the HTML generation (the code that contains the logic of the application) in a separate file and keep the file that generates the HTML page as lean as possible. E.g.: <?php include "app_logic.php"; $title = ...; . . . . . ?> <html> <head> <title><? echo $title ?></title> </head> <body> . . . . . </body> </html> This does not solve the problem completely, however. First, you still have some PHP code inside the HTML page. Second, the 'HTML' file has the extenssion ".php", which deceives some editors and they colorize it wrongly. A better soluttion to separate the HTML and PHP codes is to use a templating engine. It uses templates for generating the final HTML page. Each template is a pure HTML file, which also has some slots or variables in it. The values of these variables are calculated by the PHP code and they are passed to the engine. Then the engine reads the templates, replaces the variables by their values and thus generates an HTML page which is sent to the browser. ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=135222 |